Compare commits

..
Author SHA1 Message Date
github-actions[bot]GitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>
f5b89987af Version Packages (#1991)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-11-22 07:31:24 -08:00
Manan TankandGitHub 4bb8f5b15e Revert "add ConnectEmbed + Fix double connection issue" (#1996) 2023-11-22 15:11:43 +00:00
FirekeeperandGitHub 914befda16 [Unity] Add new tx/block processing methods to match static C# counterparts (#1995) 2023-11-22 11:31:25 +00:00
Joaquim VergesandGitHub b5bbe2bd43 [Wallets] Look at last 10 blocks for recently submitted userOp (#1992) 2023-11-22 04:52:24 +00:00
Kien NgoandGitHub 68288436ac [React, React native] Remove overrides prop from Web3Button (#1994) 2023-11-22 01:23:55 +00:00
Jonas DanielsandGitHub d4ce855e5f chore(chains): update chains & deprecate allChains (#1990) 2023-11-22 01:13:04 +00:00
Kien NgoandGitHub 47b0ed5171 [sdk, chains] Add Arb Sepolia to defaultChains (#1967) 2023-11-21 22:05:17 +00:00
github-actions[bot]GitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>
00b9eea9ec Version Packages (#1980)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-11-21 13:37:37 -08:00
iketwandGitHub bf27b88728 [RN] Improves error messages for embedded wallet (#1989) 2023-11-21 19:41:23 +00:00
Tair AsimandGitHub 17fe41d42b fix: api key caching ttl (#1988) 2023-11-21 17:38:59 +00:00
Tair AsimandGitHub 36600decef chore: add logging to authenticate (#1973) 2023-11-21 17:08:22 +00:00
FirekeeperandGitHub e09221f1e0 [Unity] SW Account Override Support (#1986) 2023-11-21 12:16:28 +00:00
FirekeeperandGitHub 62cc785c4a [Unity] Support Add/Remove Admin and Create Session Key for SW (#1985) 2023-11-21 10:42:57 +00:00
Adam MajmudarandGitHub 7c45941b57 Add support for executeMetaTransaction (#1974) 2023-11-20 19:12:11 +00:00
FirekeeperandGitHub 7a2e0edab4 [Unity] Apple and Facebook logins (#1981) 2023-11-20 18:45:33 +00:00
Manan TankandGitHub fb0cb676b9 add ConnectEmbed + Fix double connection issue with Safe/Smart in ConnectWallet (#1952) 2023-11-20 17:56:55 +00:00
12d85dec10 [React/RN] Move usePersonalWalletAddress hook to core (#1971)
Co-authored-by: Manan Tank <[email protected]>
2023-11-20 17:29:32 +00:00
1094a03a04 [wallet, react] Add Coin98 Wallet (#1921)
Co-authored-by: Manan Tank <[email protected]>
2023-11-20 16:27:00 +00:00
github-actions[bot]GitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>
6cc38b0680 Version Packages (#1970)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-11-18 14:30:05 -08:00
Joaquim VergesandGitHub 7abb36a7ec [Wallets] Enforce authenticated users when getting EW signers (#1978) 2023-11-18 17:21:15 +00:00
Joaquim VergesandGitHub 6832b19fc5 [Wallets] Fix potential embedded wallet autoconnect race condition (#1977) 2023-11-18 07:18:30 +00:00
nkrishangandGitHub 1c4cbedb6a Override signMessage for SmartWallet class (#1953) 2023-11-18 06:04:02 +00:00
Phillip HoandGitHub 8ff87be631 fix: Reuse response body in service utils helper (#1976) 2023-11-18 01:50:37 +00:00
YashandGitHub e43beec36a [SDK] Resolve diamond pattern facets abi (#1935) 2023-11-17 15:56:29 +00:00
106 changed files with 2282 additions and 197 deletions
+23
View File
@@ -1,5 +1,28 @@
# @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
- [#1973](https://github.com/thirdweb-dev/js/pull/1973) [`36600dec`](https://github.com/thirdweb-dev/js/commit/36600decefca7b9ebb1924757b4186b559e439f6) Thanks [@assimovt](https://github.com/assimovt)! - add logging to authenticate
- Updated dependencies [[`1094a03a`](https://github.com/thirdweb-dev/js/commit/1094a03a04f3e7ade84af0f7a6073794c0904cb1)]:
- @thirdweb-dev/wallets@2.1.8
## 4.1.10
### Patch Changes
- Updated dependencies [[`6832b19f`](https://github.com/thirdweb-dev/js/commit/6832b19fc5eedc7c17e69940a361840de0a84881), [`7abb36a7`](https://github.com/thirdweb-dev/js/commit/7abb36a7ec39766dd7da03015ccef401ef7a7863), [`1c4cbedb`](https://github.com/thirdweb-dev/js/commit/1c4cbedb6a3c9f9014ffbf83c02b998768958d96)]:
- @thirdweb-dev/wallets@2.1.7
## 4.1.9
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/auth",
"version": "4.1.9",
"version": "4.1.12",
"main": "dist/thirdweb-dev-auth.cjs.js",
"module": "dist/thirdweb-dev-auth.esm.js",
"browser": {
@@ -62,6 +62,7 @@ export async function getUser<
const token = getToken(req);
if (!token) {
console.error("Error: No auth token found");
return null;
}
@@ -75,6 +76,7 @@ export async function getUser<
},
});
} catch (err) {
console.error(`Authenticate Error: ${(err as Error)?.message}`);
return null;
}
+18
View File
@@ -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
+2 -2
View File
@@ -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;
+34
View File
@@ -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;
+1 -1
View File
@@ -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;
+2
View File
@@ -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}",
+6 -8
View File
@@ -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,
+10 -9
View File
@@ -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;
+5 -5
View File
@@ -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;
+31
View File
@@ -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;
+2 -1
View File
@@ -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",
+31
View File
@@ -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;
+31
View File
@@ -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;
+34
View File
@@ -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;
+31
View File
@@ -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;
+35
View File
@@ -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;
+22
View File
@@ -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;
+1 -1
View File
@@ -43,5 +43,5 @@ export default {
],
"shortName": "tftm",
"slug": "fantom-testnet",
"testnet": false
"testnet": true
} as const satisfies Chain;
+2 -6
View File
@@ -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;
+2 -4
View File
@@ -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;
+49
View File
@@ -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;
+1 -1
View File
@@ -45,5 +45,5 @@ export default {
"shortName": "synapse-sepolia",
"slug": "synapse-chain-testnet",
"status": "active",
"testnet": false
"testnet": true
} as const satisfies Chain;
+3 -3
View File
@@ -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;
-1
View File
@@ -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",
+1 -1
View File
@@ -35,5 +35,5 @@ export default {
],
"shortName": "iotex-testnet",
"slug": "iotex-network-testnet",
"testnet": false
"testnet": true
} as const satisfies Chain;
+35
View File
@@ -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;
+2 -4
View File
@@ -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;
+3 -1
View File
@@ -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",
+1 -1
View File
@@ -44,5 +44,5 @@ export default {
],
"shortName": "metis-goerli",
"slug": "metis-goerli-testnet",
"testnet": false
"testnet": true
} as const satisfies Chain;
+31
View File
@@ -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;
+31
View File
@@ -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;
+22
View File
@@ -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;
+36
View File
@@ -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;
+3 -3
View File
@@ -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",
+26
View File
@@ -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;
+1 -3
View File
@@ -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;
+31
View File
@@ -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;
+1 -1
View File
@@ -42,5 +42,5 @@ export default {
],
"shortName": "bnbt",
"slug": "binance-testnet",
"testnet": false
"testnet": true
} as const satisfies Chain;
+31
View File
@@ -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;
+2
View File
@@ -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 -1
View File
@@ -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": {
+11 -1
View File
@@ -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 & {}),
) {
+50 -1
View File
@@ -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
+28
View File
@@ -1,5 +1,33 @@
# 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
- Updated dependencies [[`36600dec`](https://github.com/thirdweb-dev/js/commit/36600decefca7b9ebb1924757b4186b559e439f6), [`1094a03a`](https://github.com/thirdweb-dev/js/commit/1094a03a04f3e7ade84af0f7a6073794c0904cb1), [`7c45941b`](https://github.com/thirdweb-dev/js/commit/7c45941b57fb5a6f83be507ee64dbf885d93c9d4)]:
- @thirdweb-dev/auth@4.1.11
- @thirdweb-dev/wallets@2.1.8
- @thirdweb-dev/sdk@4.0.16
## 0.13.18
### Patch Changes
- Updated dependencies [[`6832b19f`](https://github.com/thirdweb-dev/js/commit/6832b19fc5eedc7c17e69940a361840de0a84881), [`7abb36a7`](https://github.com/thirdweb-dev/js/commit/7abb36a7ec39766dd7da03015ccef401ef7a7863), [`1c4cbedb`](https://github.com/thirdweb-dev/js/commit/1c4cbedb6a3c9f9014ffbf83c02b998768958d96), [`e43beec3`](https://github.com/thirdweb-dev/js/commit/e43beec36a569211b6fe708107aa7dc04bff08ec)]:
- @thirdweb-dev/wallets@2.1.7
- @thirdweb-dev/sdk@4.0.15
- @thirdweb-dev/auth@4.1.10
## 0.13.17
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "thirdweb",
"main": "dist/cli/index.js",
"version": "0.13.17",
"version": "0.13.20",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/cli",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
+52
View File
@@ -1,5 +1,57 @@
# @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
- [#1952](https://github.com/thirdweb-dev/js/pull/1952) [`fb0cb676`](https://github.com/thirdweb-dev/js/commit/fb0cb676b996fe386dcc53b5a6dab03f88e76175) Thanks [@MananTank](https://github.com/MananTank)! - - Add `ConnectEmbed`` component to embed the ConnectWallet's Modal UI directly in page
- Fix `ConnectWallet` component setting personal wallet as "connected" wallet when connecting a Safe / Smart Wallet
- [#1921](https://github.com/thirdweb-dev/js/pull/1921) [`1094a03a`](https://github.com/thirdweb-dev/js/commit/1094a03a04f3e7ade84af0f7a6073794c0904cb1) Thanks [@kien-ngo](https://github.com/kien-ngo)! - Add Coin98 wallet
- [#1971](https://github.com/thirdweb-dev/js/pull/1971) [`12d85dec`](https://github.com/thirdweb-dev/js/commit/12d85dec10f47d6520b737a23576e4f832abb47f) Thanks [@iketw](https://github.com/iketw)! - Adds usePersonalWalletAddress hook to React/RN
```typescript
// React
import { usePersonalWalletAddress } from "@thirdweb-dev/react";
const personalWalletAddress = usePersonalWalletAddress();
```
```typescript
// React-Native
import { usePersonalWalletAddress } from "@thirdweb-dev/react-native";
const personalWalletAddress = usePersonalWalletAddress();
```
- Updated dependencies [[`36600dec`](https://github.com/thirdweb-dev/js/commit/36600decefca7b9ebb1924757b4186b559e439f6), [`1094a03a`](https://github.com/thirdweb-dev/js/commit/1094a03a04f3e7ade84af0f7a6073794c0904cb1), [`7c45941b`](https://github.com/thirdweb-dev/js/commit/7c45941b57fb5a6f83be507ee64dbf885d93c9d4)]:
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
## 4.1.8
### Patch Changes
- Updated dependencies [[`6832b19f`](https://github.com/thirdweb-dev/js/commit/6832b19fc5eedc7c17e69940a361840de0a84881), [`7abb36a7`](https://github.com/thirdweb-dev/js/commit/7abb36a7ec39766dd7da03015ccef401ef7a7863), [`1c4cbedb`](https://github.com/thirdweb-dev/js/commit/1c4cbedb6a3c9f9014ffbf83c02b998768958d96), [`e43beec3`](https://github.com/thirdweb-dev/js/commit/e43beec36a569211b6fe708107aa7dc04bff08ec)]:
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
## 4.1.7
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/react-core",
"version": "4.1.7",
"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",
@@ -2,6 +2,7 @@ import { useWalletContext } from "../providers/thirdweb-wallet-provider";
import invariant from "tiny-invariant";
import type {
BloctoWallet,
Coin98Wallet,
CoinbaseWallet,
CoreWallet,
EmbeddedWallet,
@@ -26,6 +27,7 @@ export type WalletId = (typeof walletIds)[keyof typeof walletIds];
type WalletIdToWalletTypeMap = {
metamask: MetaMaskWallet;
coin98: Coin98Wallet;
coinbase: CoinbaseWallet;
coreWallet: CoreWallet;
rainbowWallet: RainbowWallet;
@@ -0,0 +1,27 @@
import { useEffect, useState } from "react";
import { useWallet } from "../../core/hooks/wallet-hooks";
export const usePersonalWalletAddress = () => {
const [personalWalletAddress, setPersonalWalletAddress] = useState<
string | undefined
>();
const activeWallet = useWallet();
useEffect(() => {
(async () => {
const possiblePersonalWallet = activeWallet?.getPersonalWallet();
if (!possiblePersonalWallet) {
setPersonalWalletAddress(undefined);
return;
}
const address = await (
await possiblePersonalWallet?.getSigner()
)?.getAddress();
setPersonalWalletAddress(address);
})();
}, [activeWallet]);
return personalWalletAddress;
};
+1
View File
@@ -22,6 +22,7 @@ export {
} from "../core/hooks/wallet-hooks";
export { useNetwork } from "../core/hooks/useNetwork";
export { useWalletContext } from "../core/providers/thirdweb-wallet-provider";
export { usePersonalWalletAddress } from "./hooks/usePersonalWalletAddress";
// connected wallet hooks
export {
@@ -1,5 +1,11 @@
# @thirdweb-dev/react-native-compat
## 0.4.10
## 0.4.9
## 0.4.8
## 0.4.7
## 0.4.6
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@thirdweb-dev/react-native-compat",
"description": "Shims for Thirdweb in React Native Projects",
"version": "0.4.7",
"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",
+48
View File
@@ -1,5 +1,53 @@
# @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
- [#1971](https://github.com/thirdweb-dev/js/pull/1971) [`12d85dec`](https://github.com/thirdweb-dev/js/commit/12d85dec10f47d6520b737a23576e4f832abb47f) Thanks [@iketw](https://github.com/iketw)! - Adds usePersonalWalletAddress hook to React/RN
```typescript
// React
import { usePersonalWalletAddress } from "@thirdweb-dev/react";
const personalWalletAddress = usePersonalWalletAddress();
```
```typescript
// React-Native
import { usePersonalWalletAddress } from "@thirdweb-dev/react-native";
const personalWalletAddress = usePersonalWalletAddress();
```
- [#1989](https://github.com/thirdweb-dev/js/pull/1989) [`bf27b887`](https://github.com/thirdweb-dev/js/commit/bf27b8872870c08bb19934d87e574e0477c9550f) Thanks [@iketw](https://github.com/iketw)! - Improves EmbeddedWallet error messages in React Native
- Updated dependencies [[`fb0cb676`](https://github.com/thirdweb-dev/js/commit/fb0cb676b996fe386dcc53b5a6dab03f88e76175), [`1094a03a`](https://github.com/thirdweb-dev/js/commit/1094a03a04f3e7ade84af0f7a6073794c0904cb1), [`7c45941b`](https://github.com/thirdweb-dev/js/commit/7c45941b57fb5a6f83be507ee64dbf885d93c9d4), [`12d85dec`](https://github.com/thirdweb-dev/js/commit/12d85dec10f47d6520b737a23576e4f832abb47f)]:
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
## 0.4.8
### Patch Changes
- Updated dependencies [[`6832b19f`](https://github.com/thirdweb-dev/js/commit/6832b19fc5eedc7c17e69940a361840de0a84881), [`7abb36a7`](https://github.com/thirdweb-dev/js/commit/7abb36a7ec39766dd7da03015ccef401ef7a7863), [`1c4cbedb`](https://github.com/thirdweb-dev/js/commit/1c4cbedb6a3c9f9014ffbf83c02b998768958d96), [`e43beec3`](https://github.com/thirdweb-dev/js/commit/e43beec36a569211b6fe708107aa7dc04bff08ec)]:
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
## 0.4.7
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/react-native",
"version": "0.4.7",
"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",
@@ -13,12 +13,12 @@ import { ModalHeaderTextClose } from "../base/modal/ModalHeaderTextClose";
import {
shortenAddress,
useAddress,
usePersonalWalletAddress,
useWallet,
} from "@thirdweb-dev/react-core";
import { PasswordInput } from "../PasswordInput";
import * as FileSystem from "expo-file-system";
import { SmartWallet } from "@thirdweb-dev/wallets";
import { usePersonalWalletAddress } from "../../wallets/hooks/usePersonalWalletAddress";
import { LocalWallet } from "../../wallets/wallets/LocalWallet";
import { TWModal } from "../base/modal/TWModal";
import { useLocale } from "../../providers/ui-context-provider";
@@ -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
@@ -25,11 +25,13 @@ import { getCognitoUser, setCognitoUser } from "./helpers/storage/state";
import { isDeviceSharePresentForUser } from "./helpers/storage/local";
import { Auth } from "aws-amplify";
import {
DOMAIN_URL_2023,
ROUTE_AUTH_JWT_CALLBACK,
ROUTE_HEADLESS_OAUTH_LOGIN,
} from "./helpers/constants";
import { AuthOptions, OauthOption, VerifiedTokenResponse } from "../types";
import { InAppBrowser } from "react-native-inappbrowser-reborn";
import { createErrorMessage } from "./helpers/errors";
export async function sendVerificationEmail(options: {
email: string;
@@ -50,7 +52,7 @@ export async function sendVerificationEmail(options: {
});
} catch (e) {
throw new Error(
`Malformed response from the send email OTP API: ${JSON.stringify(e)}`,
createErrorMessage("Malformed response from the send email OTP API", e),
);
}
@@ -102,7 +104,7 @@ export async function validateEmailOTP(options: {
});
} catch (e) {
throw new Error(
`Malformed response from the send email OTP API: ${JSON.stringify(e)}`,
createErrorMessage("Malformed response validating the OTP", e),
);
}
let verifiedTokenResponse: VerifiedTokenResponse;
@@ -163,9 +165,10 @@ export async function validateEmailOTP(options: {
return { storedToken };
} catch (e) {
throw new Error(
`Malformed response from the verify one time password: ${
(e as Error).message
}}`,
createErrorMessage(
"Malformed response from the verify one time password",
e,
),
);
}
}
@@ -173,7 +176,7 @@ export async function validateEmailOTP(options: {
export async function socialLogin(oauthOptions: OauthOption, clientId: string) {
const encodedProvider = encodeURIComponent(oauthOptions.provider);
const headlessLoginLinkWithParams = `${ROUTE_HEADLESS_OAUTH_LOGIN}?authProvider=${encodedProvider}&baseUrl=${encodeURIComponent(
`https://embedded-wallet.thirdweb.com`,
DOMAIN_URL_2023,
)}&platform=${encodeURIComponent("mobile")}`;
const resp = await fetch(headlessLoginLinkWithParams);
@@ -188,7 +191,7 @@ export async function socialLogin(oauthOptions: OauthOption, clientId: string) {
const { platformLoginLink } = json;
const completeLoginUrl = `${platformLoginLink}?developerClientId=${encodeURIComponent(
clientId || "",
clientId,
)}&platform=${encodeURIComponent("mobile")}&redirectUrl=${encodeURIComponent(
oauthOptions.redirectUrl,
)}&authOption=${encodedProvider}`;
@@ -243,7 +246,7 @@ export async function socialLogin(oauthOptions: OauthOption, clientId: string) {
return { storedToken, email: storedToken.authDetails.email };
} catch (e) {
throw new Error(
`Malformed response from post authentication: ${JSON.stringify(e)}`,
createErrorMessage("Malformed response from post authentication", e),
);
}
}
@@ -285,7 +288,7 @@ export async function customJwt(authOptions: AuthOptions, clientId: string) {
return { verifiedToken, email: verifiedToken.authDetails.email };
} catch (e) {
throw new Error(
`Malformed response from post authentication: ${JSON.stringify(e)}`,
createErrorMessage("Malformed response from post authentication", e),
);
}
}
@@ -18,6 +18,7 @@ import {
IsValidUserManagedEmailOTPResponse,
VerifiedTokenResponse,
} from "../../../types";
import { createErrorMessage } from "../errors";
const EMBEDDED_WALLET_TOKEN_HEADER = "embedded-wallet-token";
const PAPER_CLIENT_ID_HEADER = "x-thirdweb-client-id";
@@ -281,7 +282,7 @@ export async function getUserShares(clientId: string, getShareUrl: URL) {
};
} catch (e) {
throw new Error(
`Malformed response from the ews user wallet API: ${JSON.stringify(e)}`,
createErrorMessage("Malformed response from the ews user wallet API", e),
);
}
}
@@ -19,7 +19,8 @@ export const COGNITO_IDENTITY_POOL_ID =
export const GENERATE_RECOVERY_PASSWORD_LAMBDA_FUNCTION =
"arn:aws:lambda:us-west-2:324457261097:function:recovery-share-password-GenerateRecoverySharePassw-bbE5ZbVAToil";
const BASE_URL_2023 = "https://embedded-wallet.thirdweb.com/";
export const DOMAIN_URL_2023 = "https://embedded-wallet.thirdweb.com";
const BASE_URL_2023 = `${DOMAIN_URL_2023}/`;
const ROUTE_2023_10_20_API_BASE_PATH = `${BASE_URL_2023}api/2023-10-20`;
export const ROUTE_GET_EMBEDDED_WALLET_DETAILS = `${ROUTE_2023_10_20_API_BASE_PATH}/embedded-wallet/embedded-wallet-user-details`;
@@ -3,3 +3,11 @@ export const ErrorMessages = {
"Your OTP code is invalid or expired. Please request a new code or try again.",
missingRecoveryCode: "Missing encryption key for user",
};
export const createErrorMessage = (message: string, error: any): string => {
if (error instanceof Error) {
return `${message}: ${error.message}`;
} else {
return `${message}: ${JSON.stringify(error)}`;
}
};
@@ -12,6 +12,7 @@ import {
} from "../constants";
import { setDeviceShare } from "../storage/local";
import { encryptShareWeb } from "./encryption";
import { createErrorMessage } from "../errors";
export async function setUpNewUserWallet(
recoveryCode: string,
@@ -145,9 +146,10 @@ export async function storeShares<R extends string | undefined>({
}
} catch (e) {
throw new Error(
`Malformed response from the ews store user share API: ${JSON.stringify(
createErrorMessage(
"Malformed response from the ews store user share API",
e,
)}`,
),
);
}
}
@@ -1,23 +0,0 @@
import { useWallet } from "@thirdweb-dev/react-core";
import { AbstractClientWallet, SmartWallet } from "@thirdweb-dev/wallets";
import { useEffect, useState } from "react";
export const usePersonalWalletAddress = () => {
const [personalWalletAddress, setPersonalWalletAddress] = useState<
string | undefined
>();
const activeWallet = useWallet();
useEffect(() => {
(async () => {
if (activeWallet?.walletId === SmartWallet.id) {
const address = await (
activeWallet.getPersonalWallet() as AbstractClientWallet
).getAddress();
setPersonalWalletAddress(address);
}
})();
}, [activeWallet]);
return personalWalletAddress;
};
+38
View File
@@ -1,5 +1,43 @@
# @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
- [#1952](https://github.com/thirdweb-dev/js/pull/1952) [`fb0cb676`](https://github.com/thirdweb-dev/js/commit/fb0cb676b996fe386dcc53b5a6dab03f88e76175) Thanks [@MananTank](https://github.com/MananTank)! - - Add `ConnectEmbed`` component to embed the ConnectWallet's Modal UI directly in page
- Fix `ConnectWallet` component setting personal wallet as "connected" wallet when connecting a Safe / Smart Wallet
- [#1921](https://github.com/thirdweb-dev/js/pull/1921) [`1094a03a`](https://github.com/thirdweb-dev/js/commit/1094a03a04f3e7ade84af0f7a6073794c0904cb1) Thanks [@kien-ngo](https://github.com/kien-ngo)! - Add Coin98 wallet
- Updated dependencies [[`fb0cb676`](https://github.com/thirdweb-dev/js/commit/fb0cb676b996fe386dcc53b5a6dab03f88e76175), [`1094a03a`](https://github.com/thirdweb-dev/js/commit/1094a03a04f3e7ade84af0f7a6073794c0904cb1), [`7c45941b`](https://github.com/thirdweb-dev/js/commit/7c45941b57fb5a6f83be507ee64dbf885d93c9d4), [`12d85dec`](https://github.com/thirdweb-dev/js/commit/12d85dec10f47d6520b737a23576e4f832abb47f)]:
- @thirdweb-dev/react-core@4.1.9
- @thirdweb-dev/wallets@2.1.8
- @thirdweb-dev/sdk@4.0.16
## 4.1.8
### Patch Changes
- Updated dependencies [[`6832b19f`](https://github.com/thirdweb-dev/js/commit/6832b19fc5eedc7c17e69940a361840de0a84881), [`7abb36a7`](https://github.com/thirdweb-dev/js/commit/7abb36a7ec39766dd7da03015ccef401ef7a7863), [`1c4cbedb`](https://github.com/thirdweb-dev/js/commit/1c4cbedb6a3c9f9014ffbf83c02b998768958d96), [`e43beec3`](https://github.com/thirdweb-dev/js/commit/e43beec36a569211b6fe708107aa7dc04bff08ec)]:
- @thirdweb-dev/wallets@2.1.7
- @thirdweb-dev/sdk@4.0.15
- @thirdweb-dev/react-core@4.1.8
## 4.1.7
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/react",
"version": "4.1.7",
"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
View File
@@ -73,4 +73,5 @@ export {
InjectedWallet,
setWalletAnalyticsEnabled,
CoreWallet,
Coin98Wallet,
} from "@thirdweb-dev/wallets";
+1
View File
@@ -168,6 +168,7 @@ export function enDefault() {
trustWallet: extensionAndQRScanScreens("Trust"),
zerionWallet: extensionAndQRScanScreens("Zerion"),
coreWallet: extensionAndQRScanScreens("Core"),
coin98Wallet: extensionAndQRScanScreens("Coin98"),
paperWallet: {
signIn: "Sign in",
signInWithGoogle: "Sign in with Google",
+1
View File
@@ -168,6 +168,7 @@ export function esDefault(): ThirdwebLocale {
metamaskWallet: extensionAndQRScanScreens("MetaMask"),
okxWallet: extensionAndQRScanScreens("OKX"),
coreWallet: extensionAndQRScanScreens("Core"),
coin98Wallet: extensionAndQRScanScreens("Coin98"),
phantomWallet: extensionAndQRScanScreens("Phantom"),
rainbowWallet: extensionAndQRScanScreens("Rainbow"),
trustWallet: extensionAndQRScanScreens("Trust"),
+1
View File
@@ -168,6 +168,7 @@ export function jaDefault(): ThirdwebLocale {
metamaskWallet: extensionAndQRScanScreens("MetaMask"),
okxWallet: extensionAndQRScanScreens("OKX"),
coreWallet: extensionAndQRScanScreens("Core"),
coin98Wallet: extensionAndQRScanScreens("Coin98"),
phantomWallet: extensionAndQRScanScreens("Phantom"),
rainbowWallet: extensionAndQRScanScreens("Rainbow"),
trustWallet: extensionAndQRScanScreens("Trust"),
+1
View File
@@ -20,6 +20,7 @@ export { walletConnectV1 } from "./wallet/wallets/walletConnectV1";
export { zerionWallet } from "./wallet/wallets/zerion/zerionWallet";
export { okxWallet } from "./wallet/wallets/okx/okxWallet";
export { coreWallet } from "./wallet/wallets/coreWallet/coreWallet";
export { coin98Wallet } from "./wallet/wallets/coin98/coin98Wallet";
export { darkTheme, lightTheme } from "./design-system/index";
export type { Theme, ThemeOverrides } from "./design-system/index";
@@ -0,0 +1,148 @@
import { ConnectUIProps, useConnect } from "@thirdweb-dev/react-core";
import { ConnectingScreen } from "../../ConnectWallet/screens/ConnectingScreen";
import { isMobile } from "../../../evm/utils/isMobile";
import { useCallback, useEffect, useRef, useState } from "react";
import { GetStartedScreen } from "../../ConnectWallet/screens/GetStartedScreen";
import type { Coin98Wallet } from "@thirdweb-dev/wallets";
import { wait } from "../../../utils/wait";
import { useTWLocale } from "../../../evm/providers/locale-provider";
import { Coin98Scan } from "./Coin98Scan";
import { WCOpenURI } from "../../ConnectWallet/screens/WCOpenUri";
import { coin98WalletUris } from "./coin98WalletUris";
export const Coin98ConnectUI = (props: ConnectUIProps<Coin98Wallet>) => {
const [screen, setScreen] = useState<
"connecting" | "scanning" | "get-started" | "open-wc-uri"
>("connecting");
const locale = useTWLocale().wallets.coin98Wallet;
const connectingLocale = {
getStartedLink: locale.getStartedLink,
instruction: locale.connectionScreen.instruction,
tryAgain: locale.connectionScreen.retry,
inProgress: locale.connectionScreen.inProgress,
failed: locale.connectionScreen.failed,
};
const { walletConfig, connected } = props;
const connect = useConnect();
const [errorConnecting, setErrorConnecting] = useState(false);
const hideBackButton = props.supportedWallets.length === 1;
const connectToExtension = useCallback(async () => {
try {
connectPrompted.current = true;
setErrorConnecting(false);
setScreen("connecting");
await wait(1000);
await connect(walletConfig);
connected();
} catch (e) {
setErrorConnecting(true);
console.error(e);
}
}, [connected, connect, walletConfig]);
const connectPrompted = useRef(false);
useEffect(() => {
if (connectPrompted.current) {
return;
}
const isInstalled = walletConfig.isInstalled
? walletConfig.isInstalled()
: false;
// if loading
(async () => {
if (isInstalled) {
connectToExtension();
}
// if wallet is not injected
else {
// on mobile, open the Coin98 Mobile via wallet connect
if (isMobile()) {
setScreen("open-wc-uri");
} else {
// on desktop, show the Coin98 app scan qr code
setScreen("scanning");
}
}
})();
}, [connectToExtension, walletConfig]);
if (screen === "connecting") {
return (
<ConnectingScreen
locale={{
getStartedLink: locale.getStartedLink,
instruction: locale.connectionScreen.instruction,
tryAgain: locale.connectionScreen.retry,
inProgress: locale.connectionScreen.inProgress,
failed: locale.connectionScreen.failed,
}}
errorConnecting={errorConnecting}
onGetStarted={() => {
setScreen("get-started");
}}
onRetry={connectToExtension}
hideBackButton={hideBackButton}
onBack={props.goBack}
walletName={walletConfig.meta.name}
walletIconURL={walletConfig.meta.iconURL}
/>
);
}
if (screen === "open-wc-uri") {
return (
<WCOpenURI
locale={connectingLocale}
onRetry={() => {
// NOOP - TODO make onRetry optional
}}
errorConnecting={errorConnecting}
onGetStarted={() => {
setScreen("get-started");
}}
hideBackButton={hideBackButton}
onBack={props.goBack}
onConnected={connected}
walletConfig={walletConfig}
appUriPrefix={coin98WalletUris}
/>
);
}
if (screen === "get-started") {
return (
<GetStartedScreen
locale={{
scanToDownload: locale.getStartedScreen.instruction,
}}
walletIconURL={walletConfig.meta.iconURL}
walletName={walletConfig.meta.name}
chromeExtensionLink={walletConfig.meta.urls?.chrome}
googlePlayStoreLink={walletConfig.meta.urls?.android}
appleStoreLink={walletConfig.meta.urls?.ios}
onBack={props.goBack}
/>
);
}
if (screen === "scanning") {
return (
<Coin98Scan
onBack={props.goBack}
onConnected={props.connected}
onGetStarted={() => {
setScreen("get-started");
}}
hideBackButton={hideBackButton}
walletConfig={walletConfig}
/>
);
}
return null;
};
@@ -0,0 +1,65 @@
import { ScanScreen } from "../../ConnectWallet/screens/ScanScreen";
import {
useCreateWalletInstance,
useWalletContext,
} from "@thirdweb-dev/react-core";
import { useEffect, useRef, useState } from "react";
import type { Coin98Wallet } from "@thirdweb-dev/wallets";
import type { WalletConfig } from "@thirdweb-dev/react-core";
import { useTWLocale } from "../../../evm/providers/locale-provider";
export const Coin98Scan: React.FC<{
onBack: () => void;
onGetStarted: () => void;
onConnected: () => void;
walletConfig: WalletConfig<Coin98Wallet>;
hideBackButton: boolean;
}> = ({ onBack, onConnected, onGetStarted, walletConfig, hideBackButton }) => {
const locale = useTWLocale().wallets.coin98Wallet;
const createInstance = useCreateWalletInstance();
const [qrCodeUri, setQrCodeUri] = useState<string | undefined>();
const { setConnectedWallet, chainToConnect, setConnectionStatus } =
useWalletContext();
const scanStarted = useRef(false);
useEffect(() => {
if (scanStarted.current) {
return;
}
scanStarted.current = true;
const wallet = createInstance(walletConfig);
setConnectionStatus("connecting");
wallet.connectWithQrCode({
chainId: chainToConnect?.chainId,
onQrCodeUri(uri) {
setQrCodeUri(uri);
},
onConnected() {
setConnectedWallet(wallet);
onConnected();
},
});
}, [
createInstance,
setConnectedWallet,
chainToConnect,
onConnected,
walletConfig,
setConnectionStatus,
]);
return (
<ScanScreen
qrScanInstruction={locale.scanScreen.instruction}
onBack={onBack}
onGetStarted={onGetStarted}
qrCodeUri={qrCodeUri}
walletName={walletConfig.meta.name}
walletIconURL={walletConfig.meta.iconURL}
hideBackButton={hideBackButton}
getStartedLink={locale.getStartedLink}
/>
);
};
@@ -0,0 +1,52 @@
import type { WalletOptions, WalletConfig } from "@thirdweb-dev/react-core";
import { Coin98Wallet, getInjectedCoin98Provider } from "@thirdweb-dev/wallets";
import { Coin98ConnectUI } from "./Coin98ConnectUI";
type Coin98WalletOptions = {
/**
* When connecting Coin98 using the QR Code - Wallet Connect connector is used which requires a project id.
* This project id is Your project’s unique identifier for wallet connect that can be obtained at cloud.walletconnect.com.
*
* https://docs.walletconnect.com/2.0/web3modal/options#projectid-required
*/
projectId?: string;
/**
* If true, the wallet will be tagged as "reccomended" in ConnectWallet Modal
*/
recommended?: boolean;
};
export const coin98Wallet = (
options?: Coin98WalletOptions,
): WalletConfig<Coin98Wallet> => {
return {
id: Coin98Wallet.id,
recommended: options?.recommended,
meta: {
name: "Coin98 Wallet",
urls: {
chrome:
"https://chrome.google.com/webstore/detail/coin98-wallet/aeachknmefphepccionboohckonoeemg",
android:
"https://play.google.com/store/apps/details?id=coin98.crypto.finance.media",
ios: "https://apps.apple.com/us/app/coin98-super-wallet/id1561969966",
},
iconURL:
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEYAAABGCAMAAABG8BK2AAACf1BMVEUAAAD//wD/gAD/qlW/v0DMzDPVqivbtiTfv0DjqjnmszPRuS7VqivYsTvbtjfduzPfrzDStC3VuDnXrjbesTfVtTXWuDPYsTHZsy/bti7csDXdszPWtTHYsi7atDXcsTLWszDXtS/YtzTZszPatDLbsi/XtTPZszHatTDbtjTbszPXtDLYtTHZsjDZszTatTPbtjLbszHXtDDYtjTZszPZtDLatTHbsjHXszTYtDPYtjLatDHatTTbszPXtDLYtTLZszTatDPatTLbszLYtDHZszPZszLatDLatTHYtDPZszLZtDHatTHYszLZtTHatTLaszLYtDHYtDHZtTPatTLYtDPZtDPZtTLZszLatTPYszPYtDLZszHatDPatTLYtDHZtTPZszPZtDLZtDPZtTLZszLZtDHatDHYszPYtDLZtTHZszHatDPatTLYszLZtDHZtTPZtDLatDLatTLYszHZtDPZtDLZszLZtDLYtTPYtDLZtDLZtDLZszHZtDPatDLZtDLZtDHZtTPZtDLatDLYszHZtDPZtDLZtDLatDLatDPYszLZtDLZtDLZtDPatDLYtTLZszLZtDLZtDHZszLZtDHZtDLZtDLYtTLZtDLZtDLZtDLZtDHZtDLYtDLZszLZtDLZtDHZtTLatDLZszLZtDPZtDLZtTLZtDLatDLZtDPZtDLZtDLZtDLZszLZtDPatDLZtDLZtDLZtDLZtDPZtDLZtDLYtDLZtTLZtDLZtDLZtDLZtDLZtDHZszLZtDLZtDLZtDLZtDHatDLZtDLZtDLZtDLZtDLZtDLYtDLZtDLZtDLZtDLZtDLZtDLZtDLZtDLZtDLZtDLZtDL///+sdBnoAAAA03RSTlMAAQIDBAUGBwgJCgsMDQ4PEBESExcYGRobHB0eHyEiJCUmJygpKy0vMDEyMzQ1Njc4OTo7PD0+P0BBQkRFRkdISktMTU5QUVJTVVdYWVtdYGFiY2RnaWprbG5vcHJ0dXd4eXp+f4CBgoOEhoeIiYqMjY6PkJGSk5SVl5iZmpucnZ+goaOkpaanqaqrrK2usLGys7S1trq7vMDBwsPExcbHyMnKzM7P0NHS09TV1tfY2drb3N3e3+Dh4uTl5ufo6err7O3u7/Hy8/T19vf4+fr7/P3++uqKzgAAAAFiS0dE1Am7C4UAAAPWSURBVBgZrcGLf81lAMfxzzk2NrJJcoujG10QliiXhCRU0kWlUi4r1ySXmS5KF4nWbFKMUlic2pRmk5nNUouzNOf7D/X8dvbbeZ6zvV5edn7vN23C49YcrI7pOsROH1w9Noxj8k/qkoo5Idr12asuK82lTaRSaagYSqucqNJS2QfPXqWpGGOW0jYdwj8rbSfC5CkAY1irAKzikAJQRrUCUEVMAYihQKBAoECgQKBO/LVnc/7GXfVK0VS8MX/zvmZ1AnVwZGYPPN0mlMpy+qksPDmL6tUBShF7NkS7yXXyfZKFr+8+pUKuC+OwDT6uhMIQSRlFSoEcVx7ENficPN9lYutdKRdyvI5n+p6LaiyaiuchefIwbtpQq/OFN2PMlAvZzmQBWTuU8FF3jK8kHcYYVCXP2WEYUTmQ7VWMz+R7H2OcpOUYXyvhcAhYKQeyDQMeUdJ4IFwrzQFulW8UMFsOZDmDUayk7Rg7pCnAbPkWAGPlQJbvMRqV9BvGOmkWME2+ecAkOZClFAhdVVIjxlLpBeDGy0r4byCwQA5k+QHjvJIqMDZJhdB/ZZMSYqv6QaEcyFKL8YWStmKUSHU9FzdLV09+u6usWtLlxT0b5UC24cAEtWsZAWQ3SaqRKp/rj+e2JfVSjVzItgyjQL58jMfkubwwA1/O+rhSIFtDLpCxIS5PS34ICB+TcXYUtidiciHHejyjP6hojBYOx/O8jKYRuJ6UCzni83DlNcuYi+f+7b82HFs7BM9mOZArNhfbxAsyyjAy31Wr2EKMvhdlQynib+fg6/HaFXmmYnwo34sYK2RDHdQvvR3PLS9Vq9WfmcDDatc8FLhHNtSZMwd37z8l326MEiWtA0L1sqBrewejSUlHMY7Igq5tCZAty1mMUlnQta3B+EdJxzEOyYIcj0cikaflWxaJRO6TPsbYq6QtGNWyIMcsYHBcbR4A7paqQ8A0tWsZAQyRDTlWYBQp4WgYeEbSSIxt8r2BsUg25DiB0e+kPHV3YJRI2omRWRCXp2V5COj+u2zINQOjz1s1Or91AMZdVyXFx+MZ/V70XPmmO/G8IgdyVdyALWO/PH8MwJXXLAdKUZRBUqhACeUDsY2skwul2tcXX/an8tVOol1o/iWlQB00vJyLJ3t+jSwlE7vh6THzR3WAOvHvNwX5m0ovKUXDlxvzt5T8rU6gQKBAoECgQBBTAGKcVgBOcUgBOMBqBeBNxioA9xKOKm1HQ/Co0jYFo0Rp2omnd1RpKe9Fq6G/KA3lg2iTW6wu+7wXSZPL1SXRGTjCY1aVVcV0HWJVB1aMDJHwP77sAsSIUUvgAAAAAElFTkSuQmCC",
},
create: (walletOptions: WalletOptions) => {
const wallet = new Coin98Wallet({
...walletOptions,
projectId: options?.projectId,
qrcode: false,
});
return wallet;
},
connectUI: Coin98ConnectUI,
isInstalled() {
return !!getInjectedCoin98Provider();
},
};
};
@@ -0,0 +1,5 @@
export const coin98WalletUris = {
ios: "coin98://",
android: "coin98://",
other: "coin98://",
};
+19
View File
@@ -1,5 +1,24 @@
# @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
- [#1974](https://github.com/thirdweb-dev/js/pull/1974) [`7c45941b`](https://github.com/thirdweb-dev/js/commit/7c45941b57fb5a6f83be507ee64dbf885d93c9d4) Thanks [@adam-maj](https://github.com/adam-maj)! - Add support for new relayer and polygon relayer
## 4.0.15
### Patch Changes
- [#1935](https://github.com/thirdweb-dev/js/pull/1935) [`e43beec3`](https://github.com/thirdweb-dev/js/commit/e43beec36a569211b6fe708107aa7dc04bff08ec) Thanks [@kumaryash90](https://github.com/kumaryash90)! - Resolve diamond pattern facets ABIs
## 4.0.14
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/sdk",
"version": "4.0.14",
"version": "4.0.17",
"description": "The main thirdweb SDK.",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/sdk",
"license": "Apache-2.0",
@@ -7,7 +7,7 @@ import { Abi, AbiSchema } from "../../schema/contracts/custom";
import { SDKOptions } from "../../schema/sdk-options";
import { isExtensionEnabled } from "../feature-detection/isFeatureEnabled";
import { ThirdwebStorage } from "@thirdweb-dev/storage";
import { providers } from "ethers";
import { Contract, providers } from "ethers";
import { joinABIs } from "./joinABIs";
import { getPluginABI } from "./getPluginABI";
@@ -24,7 +24,7 @@ export async function getCompositeABI(
let pluginABIs: Abi[] = [];
try {
// check if contract is plugin-pattern
// check if contract is plugin-pattern / dynamic
const isPluginRouter: boolean = isExtensionEnabled(
AbiSchema.parse(abi),
"PluginRouter",
@@ -33,6 +33,13 @@ export async function getCompositeABI(
AbiSchema.parse(abi),
"DynamicContract",
);
// check if the contract has fallback function - we'll further check for diamond pattern if needed
const isFallback: boolean = isExtensionEnabled(
AbiSchema.parse(abi),
"Fallback",
);
if (isbaseRouter) {
const contract = new ContractWrapper(
provider,
@@ -68,6 +75,21 @@ export async function getCompositeABI(
// get ABIs of extension contracts
pluginABIs = await getPluginABI(plugins as any[], provider, storage);
} else if (isFallback) {
// check if diamond pattern
const dimaondAbi = [
"function facets() external view returns (tuple(address,bytes4[])[])",
];
const contract = new Contract(address, dimaondAbi, provider);
// get facets
const facets = await contract.facets();
// filter facet addresses
const facetAddresses = facets.map((item: any) => item[0]);
// get ABI of facets
pluginABIs = await getPluginABI(facetAddresses, provider, storage);
}
} catch (err) {}
@@ -74,6 +74,7 @@ import {
FEATURE_ACCOUNT_FACTORY,
FEATURE_ACCOUNT_PERMISSIONS,
FEATURE_ACCOUNT_PERMISSIONS_V1,
FEATURE_FALLBACK,
} from "./thirdweb-features";
/**
@@ -148,7 +149,8 @@ export type Feature =
| typeof FEATURE_ACCOUNT
| typeof FEATURE_ACCOUNT_PERMISSIONS
| typeof FEATURE_ACCOUNT_PERMISSIONS_V1
| typeof FEATURE_ACCOUNT_FACTORY;
| typeof FEATURE_ACCOUNT_FACTORY
| typeof FEATURE_FALLBACK;
export type Extension = Feature;
@@ -197,4 +199,5 @@ export const SUPPORTED_FEATURES: Record<string, Feature> = /* @__PURE__ */ {
[FEATURE_ACCOUNT.name]: FEATURE_ACCOUNT,
[FEATURE_NFT_LOYALTY_CARD.name]: FEATURE_NFT_LOYALTY_CARD,
[FEATURE_NFT_UPDATABLE_METADATA.name]: FEATURE_NFT_UPDATABLE_METADATA,
[FEATURE_FALLBACK.name]: FEATURE_FALLBACK,
};
@@ -19,6 +19,13 @@ import IAccountPermissions from "@thirdweb-dev/contracts-js/dist/abis/IAccountPe
import IAccountPermissionsV1 from "@thirdweb-dev/contracts-js/dist/abis/IAccountPermissions_V1.json";
import IAccount from "@thirdweb-dev/contracts-js/dist/abis/IAccount.json";
export const fallbackAbi = [
{
stateMutability: "payable",
type: "fallback",
},
];
export const getAllPluginsAbi = [
{
inputs: [],
@@ -370,3 +377,14 @@ export const FEATURE_AIRDROP_ERC1155 = {
abis: [IAirdropERC1155],
features: {},
} as const;
export const FEATURE_FALLBACK = {
name: "Fallback",
namespace: "fallback",
docLinks: {
sdk: "",
contracts: "",
},
abis: [fallbackAbi],
features: {},
} as const;
@@ -333,7 +333,8 @@ export class ContractWrapper<
if (
this.options?.gasless &&
("openzeppelin" in this.options.gasless ||
"biconomy" in this.options.gasless)
"biconomy" in this.options.gasless ||
"engine" in this.options.gasless)
) {
if (fn === "multicall" && Array.isArray(args[0]) && args[0].length > 0) {
const from = await this.getSignerAddress();
@@ -632,8 +633,211 @@ export class ContractWrapper<
): Promise<string> {
if (this.options.gasless && "biconomy" in this.options.gasless) {
return this.biconomySendFunction(transaction);
} else if (this.options.gasless && "openzeppelin" in this.options.gasless) {
return this.defenderSendFunction(transaction);
}
return this.engineSendFunction(transaction);
}
private async engineSendFunction(
transaction: GaslessTransaction,
): Promise<string> {
invariant(
this.options.gasless && "engine" in this.options.gasless,
"calling engine gasless transaction without engine config in the SDK options",
);
const request = await this.enginePrepareRequest(transaction);
const res = await fetch(this.options.gasless.engine.relayerUrl, {
...request,
headers: {
"Content-Type": "application/json",
},
});
const data = await res.json();
if (data.error) {
throw new Error(data.error?.message || JSON.stringify(data.error));
}
const queueId = data.result.queueId as string;
const engineUrl =
this.options.gasless.engine.relayerUrl.split("/relayer/")[0];
const startTime = Date.now();
while (true) {
const txRes = await fetch(`${engineUrl}/transaction/status/${queueId}`);
const txData = await txRes.json();
if (txData.result.transactionHash) {
return txData.result.transactionHash as string;
}
// Time out after 30s
if (Date.now() - startTime > 30 * 1000) {
throw new Error("timeout");
}
// Poll to check if the transaction was mined
await new Promise((resolve) => setTimeout(resolve, 2000));
}
}
private async enginePrepareRequest(transaction: GaslessTransaction) {
const signer = this.getSigner();
const provider = this.getProvider();
const storage = this.storage;
invariant(signer, "signer is not set");
try {
const { abi } = await fetchContractMetadataFromAddress(
transaction.to,
provider,
storage,
);
const chainId = (await provider.getNetwork()).chainId;
const contract = new ContractWrapper(
signer,
transaction.to,
abi,
{},
storage,
);
if (abi.find((item) => item.name === "executeMetaTransaction")) {
const name: string = await contract.call("name", []);
const domain = {
name,
version: "1",
salt: "0x" + chainId.toString(16).padStart(64, "0"), // Use 64 length hex chain id as salt
verifyingContract: transaction.to,
};
const types = {
MetaTransaction: [
{ name: "nonce", type: "uint256" },
{ name: "from", type: "address" },
{ name: "functionSignature", type: "bytes" },
],
};
const nonce = await contract.call("getNonce", [transaction.from]);
const message = {
nonce: nonce,
from: transaction.from,
functionSignature: transaction.data,
};
const { signature } = await signTypedDataInternal(
signer,
domain,
types,
message,
);
return {
method: "POST",
body: JSON.stringify({
type: "execute-meta-transaction",
request: {
from: transaction.from,
to: transaction.to,
data: transaction.data,
},
signature,
}),
};
}
} catch {
// no-op
}
if (
transaction.functionName === "approve" &&
transaction.functionArgs.length === 2
) {
const spender = transaction.functionArgs[0];
const amount = transaction.functionArgs[1];
// TODO: support DAI permit by signDAIPermit
const { message: permit, signature: sig } = await signEIP2612Permit(
signer,
transaction.to,
transaction.from,
spender,
amount,
);
const message = {
to: transaction.to,
owner: permit.owner,
spender: permit.spender,
value: BigNumber.from(permit.value).toString(),
nonce: BigNumber.from(permit.nonce).toString(),
deadline: BigNumber.from(permit.deadline).toString(),
};
return {
method: "POST",
body: JSON.stringify({
type: "permit",
request: message,
signature: sig,
}),
};
} else {
const forwarderAddress =
CONTRACT_ADDRESSES[
transaction.chainId as keyof typeof CONTRACT_ADDRESSES
].openzeppelinForwarder ||
(await computeForwarderAddress(provider, storage));
const ForwarderABI = (
await import("@thirdweb-dev/contracts-js/dist/abis/Forwarder.json")
).default;
const forwarder = new Contract(forwarderAddress, ForwarderABI, provider);
const nonce = await getAndIncrementNonce(forwarder, "getNonce", [
transaction.from,
]);
const domain = {
name: "GSNv2 Forwarder",
version: "0.0.1",
chainId: transaction.chainId,
verifyingContract: forwarderAddress,
};
const types = {
ForwardRequest,
};
const message = {
from: transaction.from,
to: transaction.to,
value: BigNumber.from(0).toString(),
gas: BigNumber.from(transaction.gasLimit).toString(),
nonce: BigNumber.from(nonce).toString(),
data: transaction.data,
};
const { signature: sig } = await signTypedDataInternal(
signer,
domain,
types,
message,
);
const signature: BytesLike = sig;
return {
method: "POST",
body: JSON.stringify({
type: "forward",
request: message,
signature,
forwarderAddress,
}),
};
}
return this.defenderSendFunction(transaction);
}
private async biconomySendFunction(
@@ -44,6 +44,8 @@ import { signTypedDataInternal } from "../../common/sign";
import { BytesLike } from "ethers";
import { CONTRACT_ADDRESSES } from "../../constants/addresses/CONTRACT_ADDRESSES";
import { getContractAddressByChainId } from "../../constants/addresses/getContractAddressByChainId";
import { getCompositeABI } from "../../common/plugin/getCompositePluginABI";
import { ContractWrapper } from "./contract-wrapper";
abstract class TransactionContext {
protected args: any[];
@@ -1019,29 +1021,76 @@ async function enginePrepareRequest(
provider: providers.Provider,
storage: ThirdwebStorage,
) {
const forwarderAddress =
CONTRACT_ADDRESSES[transaction.chainId as keyof typeof CONTRACT_ADDRESSES]
.openzeppelinForwarder ||
(await computeForwarderAddress(provider, storage));
const ForwarderABI = (
await import("@thirdweb-dev/contracts-js/dist/abis/Forwarder.json")
).default;
try {
const metadata = await fetchContractMetadataFromAddress(
transaction.to,
provider,
storage,
);
const forwarder = new Contract(forwarderAddress, ForwarderABI, provider);
const nonce = await getAndIncrementNonce(forwarder, "getNonce", [
transaction.from,
]);
const chainId = (await provider.getNetwork()).chainId;
const abi = await getCompositeABI(
transaction.to,
metadata.abi,
provider,
{},
storage,
);
const contract = new ContractWrapper(
signer,
transaction.to,
abi,
{},
storage,
);
if (abi.find((item) => item.name === "executeMetaTransaction")) {
const name: string = await contract.call("name", []);
const domain = {
name: "GSNv2 Forwarder",
version: "0.0.1",
chainId: transaction.chainId,
verifyingContract: forwarderAddress,
};
const types = {
ForwardRequest,
};
let message: ForwardRequestMessage | PermitRequestMessage;
const domain = {
name,
version: "1",
salt: "0x" + chainId.toString(16).padStart(64, "0"), // Use 64 length hex chain id as salt
verifyingContract: transaction.to,
};
const types = {
MetaTransaction: [
{ name: "nonce", type: "uint256" },
{ name: "from", type: "address" },
{ name: "functionSignature", type: "bytes" },
],
};
const nonce = await contract.call("getNonce", [transaction.from]);
const message = {
nonce: nonce,
from: transaction.from,
functionSignature: transaction.data,
};
const { signature } = await signTypedDataInternal(
signer,
domain,
types,
message,
);
return {
method: "POST",
body: JSON.stringify({
type: "execute-meta-transaction",
request: {
from: transaction.from,
to: transaction.to,
data: transaction.data,
},
signature,
}),
};
}
} catch {
// no-op
}
if (
transaction.functionName === "approve" &&
@@ -1058,18 +1107,13 @@ async function enginePrepareRequest(
amount,
);
const { r, s, v } = utils.splitSignature(sig);
message = {
const message = {
to: transaction.to,
owner: permit.owner,
spender: permit.spender,
value: BigNumber.from(permit.value).toString(),
nonce: BigNumber.from(permit.nonce).toString(),
deadline: BigNumber.from(permit.deadline).toString(),
r,
s,
v,
};
return {
@@ -1077,10 +1121,34 @@ async function enginePrepareRequest(
body: JSON.stringify({
type: "permit",
request: message,
signature: sig,
}),
};
} else {
message = {
const forwarderAddress =
CONTRACT_ADDRESSES[transaction.chainId as keyof typeof CONTRACT_ADDRESSES]
.openzeppelinForwarder ||
(await computeForwarderAddress(provider, storage));
const ForwarderABI = (
await import("@thirdweb-dev/contracts-js/dist/abis/Forwarder.json")
).default;
const forwarder = new Contract(forwarderAddress, ForwarderABI, provider);
const nonce = await getAndIncrementNonce(forwarder, "getNonce", [
transaction.from,
]);
const domain = {
name: "GSNv2 Forwarder",
version: "0.0.1",
chainId: transaction.chainId,
verifyingContract: forwarderAddress,
};
const types = {
ForwardRequest,
};
const message = {
from: transaction.from,
to: transaction.to,
value: BigNumber.from(0).toString(),
+1
View File
@@ -173,6 +173,7 @@ export { fetchSnapshotEntryForAddress } from "./common/claim-conditions/fetchSna
export { getCachedAbiForContract } from "./common/abi";
export * from "./common/ens/resolveEns";
export * from "./common/ens/resolveAddress";
export * from "./common/sign";
//#endregion @r/packages/sdk/src/evm/common/*
//#region @r/packages/sdk/src/evm/constants/*
+12
View File
@@ -1,5 +1,17 @@
# @thirdweb-dev/service-utils
## 0.4.10
### Patch Changes
- [#1988](https://github.com/thirdweb-dev/js/pull/1988) [`17fe41d4`](https://github.com/thirdweb-dev/js/commit/17fe41d42bf99ccc83669557dc48d6fd22a5a04e) Thanks [@assimovt](https://github.com/assimovt)! - fix api key caching ttl
## 0.4.9
### Patch Changes
- [#1976](https://github.com/thirdweb-dev/js/pull/1976) [`8ff87be6`](https://github.com/thirdweb-dev/js/commit/8ff87be631f1754b15e7ec4556d51e8eec5cbd18) Thanks [@arcoraven](https://github.com/arcoraven)! - Handle if error parsing JSON response in authorization helper
## 0.4.8
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/service-utils",
"version": "0.4.8",
"version": "0.4.10",
"main": "dist/thirdweb-dev-service-utils.cjs.js",
"module": "dist/thirdweb-dev-service-utils.esm.js",
"exports": {
+10 -12
View File
@@ -80,17 +80,16 @@ export async function fetchKeyMetadataFromApi(
"content-type": "application/json",
},
});
let json: ApiResponse;
let text = "";
try {
json = await response.json();
text = await response.text();
return JSON.parse(text);
} catch (e) {
throw new Error(
`Error fetching key metadata from API: ${response.status} - ${
response.statusText
} - ${await response.text()}`,
`Error fetching key metadata from API: ${response.status} - ${text}`,
);
}
return json;
}
export async function fetchAccountFromApi(
@@ -110,17 +109,16 @@ export async function fetchAccountFromApi(
authorization: `Bearer ${jwt}`,
},
});
let json: ApiAccountResponse;
let text = "";
try {
json = await response.json();
text = await response.text();
return JSON.parse(text);
} catch (e) {
throw new Error(
`Error fetching account from API: ${response.status} - ${
response.statusText
} - ${await response.text()}`,
`Error fetching account from API: ${response.status} - ${text}`,
);
}
return json;
}
export async function updateRateLimitedAt(
@@ -76,9 +76,9 @@ export async function authorize(
// if the difference is greater than the cacheTtl we want to ignore the cached data
const now = Date.now();
const diff = now - parsed.updatedAt;
const cacheTtl = cacheOptions.cacheTtlSeconds * 1000;
const cacheTtlMs = cacheOptions.cacheTtlSeconds * 1000;
// only if the diff is less than the cacheTtl do we want to use the cached key
if (diff < cacheTtl * 1000) {
if (diff < cacheTtlMs) {
accountMeta = parsed.apiKeyMeta;
}
} else {
@@ -160,9 +160,9 @@ export async function authorize(
// if the difference is greater than the cacheTtl we want to ignore the cached data
const now = Date.now();
const diff = now - parsed.updatedAt;
const cacheTtl = cacheOptions.cacheTtlSeconds * 1000;
const cacheTtlMs = cacheOptions.cacheTtlSeconds * 1000;
// only if the diff is less than the cacheTtl do we want to use the cached key
if (diff < cacheTtl * 1000) {
if (diff < cacheTtlMs) {
apiKeyMeta = parsed.apiKeyMeta;
}
} else {
+36
View File
@@ -1,5 +1,41 @@
# @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
- [#1985](https://github.com/thirdweb-dev/js/pull/1985) [`62cc785c`](https://github.com/thirdweb-dev/js/commit/62cc785c4ac6886fbc3b117bfb3d85dcf7523df1) Thanks [@0xFirekeeper](https://github.com/0xFirekeeper)! - [Unity] Support Add/Remove Admin and Create Session Key for SW
- [#1986](https://github.com/thirdweb-dev/js/pull/1986) [`e09221f1`](https://github.com/thirdweb-dev/js/commit/e09221f1e0cf89bf4a8b512c107cfa7cb9bcb82e) Thanks [@0xFirekeeper](https://github.com/0xFirekeeper)! - [Unity] Support Smart Wallet Account Override
- [#1981](https://github.com/thirdweb-dev/js/pull/1981) [`7a2e0eda`](https://github.com/thirdweb-dev/js/commit/7a2e0edab4e8c11d6c8bfc8970ed2768583a48d6) Thanks [@0xFirekeeper](https://github.com/0xFirekeeper)! - [Unity] Added Facebook and Apple providers
- Updated dependencies [[`36600dec`](https://github.com/thirdweb-dev/js/commit/36600decefca7b9ebb1924757b4186b559e439f6), [`1094a03a`](https://github.com/thirdweb-dev/js/commit/1094a03a04f3e7ade84af0f7a6073794c0904cb1), [`7c45941b`](https://github.com/thirdweb-dev/js/commit/7c45941b57fb5a6f83be507ee64dbf885d93c9d4)]:
- @thirdweb-dev/auth@4.1.11
- @thirdweb-dev/wallets@2.1.8
- @thirdweb-dev/sdk@4.0.16
## 0.2.104
### Patch Changes
- Updated dependencies [[`6832b19f`](https://github.com/thirdweb-dev/js/commit/6832b19fc5eedc7c17e69940a361840de0a84881), [`7abb36a7`](https://github.com/thirdweb-dev/js/commit/7abb36a7ec39766dd7da03015ccef401ef7a7863), [`1c4cbedb`](https://github.com/thirdweb-dev/js/commit/1c4cbedb6a3c9f9014ffbf83c02b998768958d96), [`e43beec3`](https://github.com/thirdweb-dev/js/commit/e43beec36a569211b6fe708107aa7dc04bff08ec)]:
- @thirdweb-dev/wallets@2.1.7
- @thirdweb-dev/sdk@4.0.15
- @thirdweb-dev/auth@4.1.10
## 0.2.103
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/unity-js-bridge",
"version": "0.2.103",
"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",
+114 -12
View File
@@ -5,6 +5,7 @@ import { ThirdwebSDK, ChainIdOrName } from "@thirdweb-dev/sdk";
import { ThirdwebStorage } from "@thirdweb-dev/storage";
import {
DAppMetaData,
EmbeddedWalletOauthStrategy,
SmartWalletConfig,
walletIds,
} from "@thirdweb-dev/wallets";
@@ -17,7 +18,7 @@ import { MetaMaskWallet } from "@thirdweb-dev/wallets/evm/wallets/metamask";
import { SmartWallet } from "@thirdweb-dev/wallets/evm/wallets/smart-wallet";
import { WalletConnect } from "@thirdweb-dev/wallets/evm/wallets/wallet-connect";
import { EmbeddedWallet } from "@thirdweb-dev/wallets/evm/wallets/embedded-wallet";
import { BigNumber } from "ethers";
import { BigNumber, ethers } from "ethers";
import {
Ethereum,
defaultChains,
@@ -74,6 +75,7 @@ interface TWBridge {
email?: string,
personalWallet?: PossibleWallet,
authOptions?: string,
smartWalletAccountOverride?: string,
) => Promise<string>;
disconnect: () => Promise<void>;
switchNetwork: (chainId: string) => Promise<void>;
@@ -87,6 +89,13 @@ interface TWBridge {
) => void;
fundWallet: (options: string) => Promise<void>;
exportWallet: (password: string) => Promise<string>;
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;
@@ -252,6 +261,7 @@ class ThirdwebBridge implements TWBridge {
email?: string,
personalWallet: PossibleWallet = "localWallet",
authOptions?: string,
smartWalletAccountOverride?: string,
) {
if (!this.activeSDK) {
throw new Error("SDK not initialized");
@@ -281,15 +291,31 @@ class ThirdwebBridge implements TWBridge {
chainId: chainIdNumber,
authResult,
});
} else if (authOptionsParsed.authProvider === 1) {
// GoogleManaged
const googleWindow = this.openGoogleSignInWindow();
if (!googleWindow) {
throw new Error("Failed to open google login window");
} else if (authOptionsParsed.authProvider < 4) {
// OAuth
let authProvider: EmbeddedWalletOauthStrategy;
switch (authOptionsParsed.authProvider) {
case 1:
authProvider = "google";
break;
case 2:
authProvider = "apple";
break;
case 3:
authProvider = "facebook";
break;
default:
throw new Error(
"Invalid auth provider: " + authOptionsParsed.authProvider,
);
}
const popupWindow = this.openPopupWindow();
if (!popupWindow) {
throw new Error("Failed to open login window");
}
const authResult = await embeddedWallet.authenticate({
strategy: "google",
openedWindow: googleWindow,
strategy: authProvider,
openedWindow: popupWindow,
closeOpenedWindow: (openedWindow) => {
openedWindow.close();
},
@@ -298,7 +324,7 @@ class ThirdwebBridge implements TWBridge {
chainId: chainIdNumber,
authResult,
});
} else if (authOptionsParsed.authProvider === 2) {
} else if (authOptionsParsed.authProvider === 4) {
// CustomAuth
const authResult = await embeddedWallet.authenticate({
strategy: "jwt",
@@ -326,7 +352,7 @@ class ThirdwebBridge implements TWBridge {
);
if (this.activeWallet) {
// Pass EOA and reconnect to initialize smart wallet
await this.initializeSmartWallet(smartWallet, this.activeWallet);
await this.initializeSmartWallet(smartWallet, this.activeWallet, smartWalletAccountOverride);
} else {
// If EOA wallet is not connected, throw error
throw new Error(
@@ -603,11 +629,16 @@ class ThirdwebBridge implements TWBridge {
public async initializeSmartWallet(
sw: SmartWallet,
personalWallet: AbstractClientWallet,
accountAddress?: string,
) {
if(accountAddress) {
console.debug("Initializing smart wallet with account address override:", accountAddress);
}
const personalWalletAddress = await personalWallet.getAddress();
console.debug("Personal wallet address:", personalWalletAddress);
await sw.connect({
personalWallet,
accountAddress: accountAddress,
});
if (sw.listenerCount("disconnect") === 1) {
sw.on("disconnect", () => {
@@ -627,10 +658,81 @@ class ThirdwebBridge implements TWBridge {
return localWallet;
}
public openGoogleSignInWindow() {
public async smartWalletAddAdmin(admin: string) {
if (!this.activeWallet) {
throw new Error("No wallet connected");
}
const smartWallet = this.activeWallet as SmartWallet;
const result = await smartWallet.addAdmin(admin);
return JSON.stringify({ result: result }, bigNumberReplacer);
}
public async smartWalletRemoveAdmin(admin: string) {
if (!this.activeWallet) {
throw new Error("No wallet connected");
}
const smartWallet = this.activeWallet as SmartWallet;
const result = await smartWallet.removeAdmin(admin);
return JSON.stringify({ result: result }, bigNumberReplacer);
}
public async smartWalletCreateSessionKey(options: string) {
if (!this.activeWallet) {
throw new Error("No wallet connected");
}
const smartWallet = this.activeWallet as SmartWallet;
const optionsParsed = JSON.parse(options);
const approvedCallTargets = optionsParsed.approvedCallTargets;
const nativeTokenLimitPerTransaction = ethers.utils.formatEther(
optionsParsed.nativeTokenLimitPerTransactionInWei,
);
const startDate = BigNumber.from(optionsParsed.startDate).toNumber();
const expirationDate = BigNumber.from(optionsParsed.expirationDate).toNumber();
const result = await smartWallet.createSessionKey(optionsParsed.signerAddress, {
approvedCallTargets: approvedCallTargets,
nativeTokenLimitPerTransaction: nativeTokenLimitPerTransaction,
startDate: startDate,
expirationDate: expirationDate,
});
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) {
win.document.title = "Sign In - Google Accounts";
win.document.title = "Sign In - OAuth";
win.document.body.innerHTML = `
<svg class="loader" viewBox="0 0 50 50">
<circle
+32
View File
@@ -1,5 +1,37 @@
# @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
- [#1921](https://github.com/thirdweb-dev/js/pull/1921) [`1094a03a`](https://github.com/thirdweb-dev/js/commit/1094a03a04f3e7ade84af0f7a6073794c0904cb1) Thanks [@kien-ngo](https://github.com/kien-ngo)! - Add Coin98 wallet
- Updated dependencies [[`7c45941b`](https://github.com/thirdweb-dev/js/commit/7c45941b57fb5a6f83be507ee64dbf885d93c9d4)]:
- @thirdweb-dev/sdk@4.0.16
## 2.1.7
### Patch Changes
- [#1977](https://github.com/thirdweb-dev/js/pull/1977) [`6832b19f`](https://github.com/thirdweb-dev/js/commit/6832b19fc5eedc7c17e69940a361840de0a84881) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Fix potential auto connection race condition
- [#1978](https://github.com/thirdweb-dev/js/pull/1978) [`7abb36a7`](https://github.com/thirdweb-dev/js/commit/7abb36a7ec39766dd7da03015ccef401ef7a7863) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Enforce authenticated users when getting embedded wallet signers
- [#1953](https://github.com/thirdweb-dev/js/pull/1953) [`1c4cbedb`](https://github.com/thirdweb-dev/js/commit/1c4cbedb6a3c9f9014ffbf83c02b998768958d96) Thanks [@nkrishang](https://github.com/nkrishang)! - Patched smart wallet signatures for updated eip-1271 sig verification
- Updated dependencies [[`e43beec3`](https://github.com/thirdweb-dev/js/commit/e43beec36a569211b6fe708107aa7dc04bff08ec)]:
- @thirdweb-dev/sdk@4.0.15
## 2.1.6
### Patch Changes
@@ -0,0 +1,7 @@
{
"main": "dist/thirdweb-dev-wallets-evm-connectors-coin98.cjs.js",
"module": "dist/thirdweb-dev-wallets-evm-connectors-coin98.esm.js",
"browser": {
"./dist/thirdweb-dev-wallets-evm-connectors-coin98.esm.js": "./dist/thirdweb-dev-wallets-evm-connectors-coin98.browser.esm.js"
}
}
@@ -0,0 +1,7 @@
{
"main": "dist/thirdweb-dev-wallets-evm-wallets-coin98.cjs.js",
"module": "dist/thirdweb-dev-wallets-evm-wallets-coin98.esm.js",
"browser": {
"./dist/thirdweb-dev-wallets-evm-wallets-coin98.esm.js": "./dist/thirdweb-dev-wallets-evm-wallets-coin98.browser.esm.js"
}
}
+15 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/wallets",
"version": "2.1.6",
"version": "2.1.9",
"main": "dist/thirdweb-dev-wallets.cjs.js",
"module": "dist/thirdweb-dev-wallets.esm.js",
"browser": {
@@ -77,6 +77,13 @@
},
"default": "./evm/wallets/blocto/dist/thirdweb-dev-wallets-evm-wallets-blocto.cjs.js"
},
"./evm/wallets/coin98": {
"module": {
"browser": "./evm/wallets/coin98/dist/thirdweb-dev-wallets-evm-wallets-coin98.browser.esm.js",
"default": "./evm/wallets/coin98/dist/thirdweb-dev-wallets-evm-wallets-coin98.esm.js"
},
"default": "./evm/wallets/coin98/dist/thirdweb-dev-wallets-evm-wallets-coin98.cjs.js"
},
"./evm/wallets/engine": {
"module": {
"browser": "./evm/wallets/engine/dist/thirdweb-dev-wallets-evm-wallets-engine.browser.esm.js",
@@ -245,6 +252,13 @@
},
"default": "./evm/connectors/blocto/dist/thirdweb-dev-wallets-evm-connectors-blocto.cjs.js"
},
"./evm/connectors/coin98": {
"module": {
"browser": "./evm/connectors/coin98/dist/thirdweb-dev-wallets-evm-connectors-coin98.browser.esm.js",
"default": "./evm/connectors/coin98/dist/thirdweb-dev-wallets-evm-connectors-coin98.esm.js"
},
"default": "./evm/connectors/coin98/dist/thirdweb-dev-wallets-evm-connectors-coin98.cjs.js"
},
"./evm/connectors/signer": {
"module": {
"browser": "./evm/connectors/signer/dist/thirdweb-dev-wallets-evm-connectors-signer.browser.esm.js",
@@ -0,0 +1,20 @@
import { Ethereum } from "../injected/types";
import { assertWindowEthereum } from "../../utils/assertWindowEthereum";
declare global {
interface Window {
coin98?: Ethereum;
}
}
export function getInjectedCoin98Provider(): Ethereum | undefined {
if (typeof window === "undefined") {
return;
}
if (assertWindowEthereum(globalThis.window)) {
if (window.coin98) {
return window.ethereum;
}
}
}
@@ -0,0 +1,135 @@
import { AsyncStorage } from "../../../core/AsyncStorage";
import {
ConnectorNotFoundError,
ResourceUnavailableError,
RpcError,
UserRejectedRequestError,
} from "../../../lib/wagmi-core/errors";
import { walletIds } from "../../constants/walletIds";
import { InjectedConnector, InjectedConnectorOptions } from "../injected";
import type { Chain } from "@thirdweb-dev/chains";
import { utils } from "ethers";
import { getInjectedCoin98Provider } from "./getInjectedCoin98Provider";
export type Coin98ConnectorOptions = InjectedConnectorOptions;
type Coin98ConnectorConstructorArg = {
chains?: Chain[];
connectorStorage: AsyncStorage;
options?: Coin98ConnectorOptions;
};
export class Coin98Connector extends InjectedConnector {
readonly id = walletIds.coin98;
constructor(arg: Coin98ConnectorConstructorArg) {
const defaultOptions = {
name: "Coin98 Wallet",
shimDisconnect: true,
shimChainChangedDisconnect: true,
getProvider: getInjectedCoin98Provider,
};
const options = {
...defaultOptions,
...arg.options,
};
super({
chains: arg.chains,
options,
connectorStorage: arg.connectorStorage,
});
}
/**
* Connect to injected Coin98Wallet provider
*/
async connect(options: { chainId?: number } = {}) {
try {
const provider = await this.getProvider();
if (!provider) {
throw new ConnectorNotFoundError();
}
this.setupListeners();
// emit "connecting" event
this.emit("message", { type: "connecting" });
// Attempt to show wallet select prompt with `wallet_requestPermissions` when
// `shimDisconnect` is active and account is in disconnected state (flag in storage)
let account: string | null = null;
if (
this.options?.shimDisconnect &&
!Boolean(this.connectorStorage.getItem(this.shimDisconnectKey))
) {
account = await this.getAccount().catch(() => null);
const isConnected = !!account;
if (isConnected) {
// Attempt to show another prompt for selecting wallet if already connected
try {
await provider.request({
method: "wallet_requestPermissions",
params: [{ eth_accounts: {} }],
});
} catch (error) {
// Not all injected providers support `wallet_requestPermissions` (e.g. iOS).
// Only bubble up error if user rejects request
if (this.isUserRejectedRequestError(error)) {
throw new UserRejectedRequestError(error);
}
}
}
}
// if account is not already set, request accounts and use the first account
if (!account) {
const accounts = await provider.request({
method: "eth_requestAccounts",
});
account = utils.getAddress(accounts[0] as string);
}
// get currently connected chainId
let connectedChainId = await this.getChainId();
// check if connected chain is unsupported
let isUnsupported = this.isChainUnsupported(connectedChainId);
// if chainId is given, but does not match the currently connected chainId, switch to the given chainId
if (options.chainId && connectedChainId !== options.chainId) {
try {
await this.switchChain(options.chainId);
// recalculate the chainId and isUnsupported
connectedChainId = options.chainId;
isUnsupported = this.isChainUnsupported(options.chainId);
} catch (e) {
console.error(`Could not switch to chain id : ${options.chainId}`, e);
}
}
// if shimDisconnect is enabled
if (this.options?.shimDisconnect) {
// add shimDisconnectKey in storage - this signals that connector is "connected"
await this.connectorStorage.setItem(this.shimDisconnectKey, "true");
}
const connectionInfo = {
chain: { id: connectedChainId, unsupported: isUnsupported },
provider: provider,
account,
};
this.emit("connect", connectionInfo);
return connectionInfo;
} catch (error) {
if (this.isUserRejectedRequestError(error)) {
throw new UserRejectedRequestError(error);
}
if ((error as RpcError).code === -32002) {
throw new ResourceUnavailableError(error);
}
throw error;
}
}
}
@@ -89,7 +89,7 @@ export class EmbeddedWalletConnector extends Connector<EmbeddedWalletConnectionA
if (!this.user) {
throw new Error("Embedded Wallet is not connected");
}
return this.user.walletAddress;
return await this.getSigner().then((signer) => signer.getAddress());
}
async isConnected(): Promise<boolean> {
@@ -115,7 +115,7 @@ export class EmbeddedWalletConnector extends Connector<EmbeddedWalletConnectionA
}
const user = await this.getUser();
const signer = await user?.wallet.getEthersJsSigner({
const signer = await user.wallet.getEthersJsSigner({
rpcEndpoint: this.options.chain.rpc[0] || "", // TODO: handle chain.rpc being empty array
});
@@ -180,11 +180,11 @@ export class EmbeddedWalletConnector extends Connector<EmbeddedWalletConnectionA
this.emit("disconnect");
};
async getUser(): Promise<InitializedUser | null> {
private async getUser(): Promise<InitializedUser> {
if (
!this.user ||
!this.user.wallet ||
typeof this.user.wallet.getEthersJsSigner !== "function"
!this.user.wallet.getEthersJsSigner // when serializing, functions are lost, need to rehydrate
) {
const embeddedWalletSdk = this.getEmbeddedWalletSDK();
const user = await embeddedWalletSdk.getUser();
@@ -193,27 +193,25 @@ export class EmbeddedWalletConnector extends Connector<EmbeddedWalletConnectionA
this.user = user;
break;
}
default: {
// if logged out or unitialized, we can't get a signer, so throw an error
throw new Error(
"Embedded Wallet is not authenticated, please authenticate first",
);
}
}
}
return this.user;
}
async getEmail() {
// implicit call to set the user
await this.getSigner();
if (!this.user) {
throw new Error("No user found, Embedded Wallet is not connected");
}
return this.user.authDetails.email;
const user = await this.getUser();
return user.authDetails.email;
}
async getRecoveryInformation() {
// implicit call to set the user
await this.getSigner();
if (!this.user) {
throw new Error("No user found, Embedded Wallet is not connected");
}
return this.user.authDetails;
const user = await this.getUser();
return user.authDetails;
}
async sendVerificationEmail({
@@ -64,5 +64,4 @@ export type AuthResult = {
user?: InitializedUser;
isNewUser?: boolean;
needsRecoveryCode?: boolean;
verifyOTP?: (otp: string, recoveryCode?: string) => Promise<AuthResult>;
};

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