Compare commits

...
Author SHA1 Message Date
github-actions[bot]GitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>
73bee2bed1 Version Packages (#1121)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-06-08 22:35:52 -06:00
2a443365bd [Smart Wallet] Fix Celo support (#1153)
Co-authored-by: Joaquim Verges <[email protected]>
2023-06-09 04:22:15 +00:00
Manan TankandGitHub ed47fd5310 [sdk] Reduce circular dependencies (#1152) 2023-06-08 22:01:35 +00:00
Manan TankandGitHub 2a0294d8e6 [react] Fix wrong balance in ConnectWallet (#1151) 2023-06-08 20:09:52 +00:00
Manan TankandGitHub 65ecf072eb [react] Improve rendering of long Network List in ConnectWallet Modal (#1149) 2023-06-08 19:10:45 +00:00
Manan TankandGitHub 9ce3eb6aad [react-core] Remove WalletConfig.config, Remove circular dependency (#1144) 2023-06-08 09:43:16 +00:00
Nacho IacovinoandGitHub e32faeb57a [React] Fix return type for useIsSmartWalletDeployed (#1146) 2023-06-08 00:38:59 +00:00
Nacho IacovinoandGitHub 6a19426200 [React] Add useIsSmartWalletDeployed hook (#1145) 2023-06-07 23:40:11 +00:00
iketwandGitHub 2bcad4b716 [ReactNative] make links optional (#1143) 2023-06-07 20:57:22 +00:00
FirekeeperandGitHub 193de1e9d8 [unity-js-bridge] WebGL SW Multi EOA Support (#1142) 2023-06-07 09:35:17 +00:00
645b0303cc feat: create Taro Testnet (#1138)
Co-authored-by: Jonas Daniels <[email protected]>
2023-06-07 05:22:09 +00:00
YashandGitHub 16232de9ea [Chains] Update chains (#1140) 2023-06-06 23:36:12 +00:00
Joaquim VergesandGitHub 52056edfd6 [SDK] Fix contract.call documentation (#1139) 2023-06-06 19:53:17 +00:00
iketwandGitHub dec4c4a8cf [ReactNative] Exports WCV1 and V2 abstract classes to facilitate creation of wallet connect based wallets (#1137) 2023-06-06 17:22:58 +00:00
Manan TankandGitHub 9a015a23cd [react-core] Logout user on account switch (#1136) 2023-06-06 10:39:43 +00:00
iketwandGitHub 15ef4779e0 [ReactNative] Exports base UI components for external use (#1135) 2023-06-05 22:22:37 +00:00
FirekeeperandGitHub b8498c2a10 [unity-js-bridge] sw lw persistence webgl & export (#1133) 2023-06-05 16:38:48 +00:00
56f85e57df [sdk] Reduce circular dependencies (#1124)
Co-authored-by: Joaquim Verges <[email protected]>
2023-06-05 15:22:02 +00:00
Manan TankandGitHub 197a6838f6 [wallets] Clear localWallet.ethersWallet when calling localWallet.disconnect (#1132) 2023-06-05 15:10:59 +00:00
YashandGitHub 3bf7f37593 [SDK] Fix handling of standard contracts (#1131) 2023-06-03 23:30:21 +00:00
YashandGitHub 6803c3e97c Fix any evm deploy: when not autoFactory (#1129) 2023-06-03 02:43:58 +00:00
YashandGitHub b672860397 [SDK] Enable ZKSync mainnet deployments (#1128) 2023-06-03 01:02:58 +00:00
Adam MajmudarandGitHub ab14cd8938 [Auth] Add expiration date to cookies (#1126) 2023-06-02 23:28:39 +00:00
YashandGitHub 8687d6ac3a Add missing exports (#1127) 2023-06-02 23:27:30 +00:00
YashandGitHub a5f16b6dc5 Check standard deploy type (#1125) 2023-06-02 22:19:18 +00:00
6a91b6a025 [SDK] Publish flow updates (#1016)
Co-authored-by: Nacho Iacovino <[email protected]>
2023-06-02 20:59:45 +00:00
Nacho IacovinoandGitHub 54cfd6d891 [React] Update useCreateSmartWallet (#1123) 2023-06-02 19:56:14 +00:00
Manan TankandGitHub 522453fd56 [sdk] Reduce circular dependencies (#1120) 2023-06-02 18:01:57 +00:00
Nacho IacovinoandGitHub 0cba69ca40 Export smart wallet factory hooks (#1119) 2023-06-02 17:48:15 +00:00
github-actions[bot]GitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>
96b43b8488 Version Packages (#1106)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-06-02 10:33:56 -07:00
b4c9515937 Add Smart Wallet Factory hooks (#1115)
Co-authored-by: Krishang <[email protected]>
2023-06-02 16:19:24 +00:00
Manan TankandGitHub 9b20fc9ad2 [wallets, react] Remove chain restriction in paper wallet, Fix email validation in paper & magic (#1118) 2023-06-02 15:54:48 +00:00
Manan TankandGitHub 51bbd3d1bc [sdk] Reduce circular dependencies (#1117) 2023-06-02 13:58:26 +00:00
Manan TankandGitHub 356f7aa643 [react] Fix missing connectionStatus on localWallet connection, Metamask QR connection (#1116) 2023-06-02 12:35:14 +00:00
Adam MajmudarandGitHub 2283e71aca [Auth] Switch to server-side payload generation (#1114) 2023-06-02 00:38:35 +00:00
iketwandGitHub 90ab9ab031 [RN] fix lint warning (#1113) 2023-06-01 22:13:39 +00:00
Manan TankandGitHub 6aee041343 [sdk] Reduce circular dependencies (#1112) 2023-06-01 22:07:36 +00:00
Adam MajmudarandGitHub 21627c03d1 Update auth expiration (#1111) 2023-06-01 18:48:26 +00:00
ce36322b38 [SDK] Added getNonce() & updated airdrop (#1104)
Co-authored-by: Joaquim Verges <[email protected]>
Co-authored-by: Jonas Daniels <[email protected]>
2023-06-01 17:43:55 +00:00
nkrishangandGitHub 564eaccf48 Smart Wallet Factory class for creating accounts and fetching data about them. (#1095) 2023-06-01 14:31:32 +00:00
Manan TankandGitHub aa9e952cb5 [sdk] Reduce circular dependencies (#1110) 2023-06-01 14:28:30 +00:00
Manan TankandGitHub 85a6162137 [sdk] Reduce circular deps (#1109) 2023-06-01 13:30:29 +00:00
Manan TankandGitHub e93aa70ef0 [sdk] Reduce circular deps (#1108) 2023-06-01 12:43:31 +00:00
Manan TankandGitHub 6e86123403 [sdk] Reduce circular dependencies (#1107) 2023-06-01 12:13:22 +00:00
Manan TankandGitHub c60658ed8c [sdk] Reduce circular deps (#1105) 2023-06-01 11:29:45 +00:00
github-actions[bot]GitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>
df5f016d31 Version Packages (#1099)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-05-31 16:52:33 -07:00
iketwandGitHub 89102b0c89 [RN] fix bug after scanning wc uri (#1103) 2023-05-31 23:44:10 +00:00
Adam MajmudarandGitHub e1846c4469 [Auth] Default invalid before state to 5 minutes ago (#1101) 2023-05-31 22:05:16 +00:00
Manan TankandGitHub cc56037e64 [sdk] Reduce circular dependencies (#1102) 2023-05-31 21:23:03 +00:00
Manan TankandGitHub 23d90b3e77 [sdk] Reduce circular dependencies (#1100) 2023-05-31 19:58:48 +00:00
Manan TankandGitHub 6745078947 add sideEffects: false on auth, storage, unity-js-bridge (#1098) 2023-05-31 18:52:05 +00:00
309 changed files with 8313 additions and 8644 deletions
+33
View File
@@ -1,5 +1,38 @@
# @thirdweb-dev/auth
## 3.1.1
### Patch Changes
- [#1126](https://github.com/thirdweb-dev/js/pull/1126) [`ab14cd89`](https://github.com/thirdweb-dev/js/commit/ab14cd89385aefad7f32e20a22baa9fce42b98e2) Thanks [@adam-maj](https://github.com/adam-maj)! - Add expiration date to cookie
- Updated dependencies [[`2a443365`](https://github.com/thirdweb-dev/js/commit/2a443365bdc3d47d0f41fc895f70256dcde423f5), [`197a6838`](https://github.com/thirdweb-dev/js/commit/197a6838f69ae8b9ad46524e7c469fc757d0a2cb)]:
- @thirdweb-dev/wallets@0.2.26
## 3.1.0
### Minor Changes
- [#1114](https://github.com/thirdweb-dev/js/pull/1114) [`2283e71a`](https://github.com/thirdweb-dev/js/commit/2283e71acaaf3d15eb2d6121682f1d2a81eec4f3) Thanks [@adam-maj](https://github.com/adam-maj)! - Switch to server-side payload generation
### Patch Changes
- [#1111](https://github.com/thirdweb-dev/js/pull/1111) [`21627c03`](https://github.com/thirdweb-dev/js/commit/21627c03d1bb1658fee19b12d580faa6c7f048d9) Thanks [@adam-maj](https://github.com/adam-maj)! - Update expiration dates for auth
- Updated dependencies [[`9b20fc9a`](https://github.com/thirdweb-dev/js/commit/9b20fc9ad2d303edc31f44fbd2ea3b4dcf35d11e)]:
- @thirdweb-dev/wallets@0.2.25
## 3.0.23
### Patch Changes
- [#1101](https://github.com/thirdweb-dev/js/pull/1101) [`e1846c44`](https://github.com/thirdweb-dev/js/commit/e1846c44696bcb25a6a137d63e117e7d2ce9d979) Thanks [@adam-maj](https://github.com/adam-maj)! - Bump invalid before with 5 minute window
- [#1098](https://github.com/thirdweb-dev/js/pull/1098) [`67450789`](https://github.com/thirdweb-dev/js/commit/67450789473b6008b86453ee4f4c7b99461223a6) Thanks [@MananTank](https://github.com/MananTank)! - add sideEffects: false in package.json
- Updated dependencies []:
- @thirdweb-dev/wallets@0.2.24
## 3.0.22
### Patch Changes
+2 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/auth",
"version": "3.0.22",
"version": "3.1.1",
"main": "dist/thirdweb-dev-auth.cjs.js",
"module": "dist/thirdweb-dev-auth.esm.js",
"browser": {
@@ -54,6 +54,7 @@
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/auth",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
"sideEffects": false,
"scripts": {
"build": "preconstruct build",
"format": "prettier --write 'src/**/*'",
+34 -14
View File
@@ -6,7 +6,6 @@ import {
LoginPayloadDataSchema,
AuthenticationPayloadDataSchema,
AuthenticationPayloadData,
LoginOptionsSchema,
VerifyOptionsSchema,
VerifyOptions,
GenerateOptionsSchema,
@@ -14,6 +13,8 @@ import {
AuthenticateOptions,
User,
Json,
LoginOptionsSchema,
AuthenticationPayload,
} from "./schema";
import { isBrowser } from "./utils";
import type { GenericAuthWallet } from "@thirdweb-dev/wallets";
@@ -31,7 +32,7 @@ export class ThirdwebAuth {
this.wallet = wallet;
}
public async login(options?: LoginOptions): Promise<LoginPayload> {
public async payload(options?: LoginOptions): Promise<LoginPayloadData> {
const parsedOptions = LoginOptionsSchema.parse(options);
let chainId: string | undefined = parsedOptions?.chainId;
@@ -43,30 +44,40 @@ export class ThirdwebAuth {
}
}
const payloadData = LoginPayloadDataSchema.parse({
return LoginPayloadDataSchema.parse({
type: this.wallet.type,
domain: parsedOptions?.domain || this.domain,
address: await this.wallet.getAddress(),
address: parsedOptions?.address || (await this.wallet.getAddress()),
statement: parsedOptions?.statement,
version: parsedOptions?.version,
uri: parsedOptions?.uri,
chain_id: chainId,
nonce: parsedOptions?.nonce,
expiration_time:
parsedOptions?.expirationTime || new Date(Date.now() + 1000 * 60 * 5),
invalid_before: parsedOptions?.invalidBefore,
parsedOptions?.expirationTime || new Date(Date.now() + 1000 * 60 * 10),
invalid_before:
parsedOptions?.invalidBefore || new Date(Date.now() - 1000 * 60 * 10),
resources: parsedOptions?.resources,
});
}
const message = this.generateMessage(payloadData);
public async loginWithPayload(
payload: LoginPayloadData,
): Promise<LoginPayload> {
const message = this.generateMessage(payload);
const signature = await this.wallet.signMessage(message);
return {
payload: payloadData,
payload,
signature,
};
}
public async login(options?: LoginOptions): Promise<LoginPayload> {
const payloadData = await this.payload(options);
return await this.loginWithPayload(payloadData);
}
public async verify(
payload: LoginPayload,
options?: VerifyOptions,
@@ -276,12 +287,7 @@ export class ThirdwebAuth {
const parsedOptions = AuthenticateOptionsSchema.parse(options);
const domain = parsedOptions?.domain || this.domain;
const encodedPayload = token.split(".")[1];
const encodedSignature = token.split(".")[2];
const payload: AuthenticationPayloadData = JSON.parse(
Buffer.from(encodedPayload, "base64").toString(),
);
const signature = Buffer.from(encodedSignature, "base64").toString();
const { payload, signature } = this.parseToken(token);
// Check that the payload unique ID is valid
if (parsedOptions?.validateTokenId !== undefined) {
@@ -349,6 +355,20 @@ export class ThirdwebAuth {
};
}
public parseToken(token: string): AuthenticationPayload {
const encodedPayload = token.split(".")[1];
const encodedSignature = token.split(".")[2];
const payload: AuthenticationPayloadData = JSON.parse(
Buffer.from(encodedPayload, "base64").toString(),
);
const signature = Buffer.from(encodedSignature, "base64").toString();
return {
payload,
signature,
};
}
private async verifySignature(
message: string,
signature: string,
+1
View File
@@ -34,6 +34,7 @@ const JsonSchema: z.ZodType<Json> = z.lazy(
export const LoginOptionsSchema = z
.object({
domain: z.string().optional(),
address: z.string().optional(),
statement: z.string().optional(),
uri: z.string().optional(),
version: z.string().optional(),
+8
View File
@@ -1,5 +1,6 @@
import { Json, ThirdwebAuth as ThirdwebAuthSDK } from "../core";
import { getUser } from "./helpers/user";
import payloadHandler from "./routes/payload";
import loginHandler from "./routes/login";
import logoutHandler from "./routes/logout";
import userHandler from "./routes/user";
@@ -47,6 +48,13 @@ export function ThirdwebAuth<
router.use(express.json());
router.use(cookieMiddleware);
router.post(
"/payload",
asyncHandler((req: Request, res: Response) =>
payloadHandler(req, res, ctx as ThirdwebAuthContext),
),
);
router.post(
"/login",
asyncHandler((req: Request, res: Response) =>
@@ -64,6 +64,10 @@ export default async function handler(
}
}
const {
payload: { exp },
} = ctx.auth.parseToken(token);
// Securely set httpOnly cookie on request to prevent XSS on frontend
// And set path to / to enable thirdweb_auth_token usage on all endpoints
res.setHeader(
@@ -72,6 +76,7 @@ export default async function handler(
domain: ctx.cookieOptions?.domain,
path: ctx.cookieOptions?.path || "/",
sameSite: ctx.cookieOptions?.sameSite || "none",
expires: new Date(exp * 1000),
httpOnly: true,
secure: true,
}),
@@ -0,0 +1,31 @@
import { Request, Response } from "express";
import { PayloadBodySchema, ThirdwebAuthContext } from "../types";
export default async function handler(
req: Request,
res: Response,
ctx: ThirdwebAuthContext,
) {
if (req.method !== "POST") {
return res.status(405).json({
error: "Invalid method. Only POST supported.",
});
}
const parsedPayload = PayloadBodySchema.safeParse(req.body);
if (!parsedPayload.success) {
return res.status(400).json({ error: "Please provide an address" });
}
// TODO: Add nonce generation + custom expiration + invalid before
const payload = await ctx.auth.payload({
address: parsedPayload.data.address,
statement: ctx.authOptions?.statement,
uri: ctx.authOptions?.uri,
version: ctx.authOptions?.version,
chainId: ctx.authOptions?.chainId,
resources: ctx.authOptions?.resources,
});
return res.status(200).json({ payload });
}
+4
View File
@@ -4,6 +4,10 @@ import type { GenericAuthWallet } from "@thirdweb-dev/wallets";
import { Request } from "express";
import { z } from "zod";
export const PayloadBodySchema = z.object({
address: z.string(),
});
export const LoginPayloadBodySchema = z.object({
payload: LoginPayloadOutputSchema,
});
+3
View File
@@ -1,5 +1,6 @@
import { Json, ThirdwebAuth as ThirdwebAuthSDK } from "../core";
import { getUser } from "./helpers/user";
import payloadHandler from "./routes/payload";
import loginHandler from "./routes/login";
import logoutHandler from "./routes/logout";
import userHandler from "./routes/user";
@@ -27,6 +28,8 @@ async function ThirdwebAuthRouter(
const action = thirdweb?.[0] as ThirdwebAuthRoute;
switch (action) {
case "payload":
return await payloadHandler(req, res, ctx);
case "login":
return await loginHandler(req, res, ctx);
case "user":
+5
View File
@@ -64,6 +64,10 @@ export default async function handler(
}
}
const {
payload: { exp },
} = ctx.auth.parseToken(token);
// Securely set httpOnly cookie on request to prevent XSS on frontend
// And set path to / to enable thirdweb_auth_token usage on all endpoints
res.setHeader(
@@ -72,6 +76,7 @@ export default async function handler(
domain: ctx.cookieOptions?.domain,
path: ctx.cookieOptions?.path || "/",
sameSite: ctx.cookieOptions?.sameSite || "none",
expires: new Date(exp * 1000),
httpOnly: true,
secure: true,
}),
+31
View File
@@ -0,0 +1,31 @@
import { PayloadBodySchema, ThirdwebAuthContext } from "../types";
import { NextApiRequest, NextApiResponse } from "next";
export default async function handler(
req: NextApiRequest,
res: NextApiResponse,
ctx: ThirdwebAuthContext,
) {
if (req.method !== "POST") {
return res.status(405).json({
error: "Invalid method. Only POST supported.",
});
}
const parsedPayload = PayloadBodySchema.safeParse(req.body);
if (!parsedPayload.success) {
return res.status(400).json({ error: "Please provide an address" });
}
// TODO: Add nonce generation + custom expiration + invalid before
const payload = await ctx.auth.payload({
address: parsedPayload.data.address,
statement: ctx.authOptions?.statement,
uri: ctx.authOptions?.uri,
version: ctx.authOptions?.version,
chainId: ctx.authOptions?.chainId,
resources: ctx.authOptions?.resources,
});
return res.status(200).json({ payload });
}
+5 -1
View File
@@ -5,6 +5,10 @@ import { GetServerSidePropsContext, NextApiRequest } from "next";
import { NextRequest } from "next/server";
import { z } from "zod";
export const PayloadBodySchema = z.object({
address: z.string(),
});
export const LoginPayloadBodySchema = z.object({
payload: LoginPayloadOutputSchema,
});
@@ -14,7 +18,7 @@ type RequestType =
| NextRequest
| NextApiRequest;
export type ThirdwebAuthRoute = "login" | "logout" | "user";
export type ThirdwebAuthRoute = "payload" | "login" | "logout" | "user";
export type ThirdwebAuthUser<
TData extends Json = Json,
+8
View File
@@ -1,5 +1,13 @@
# @thirdweb-dev/chains
## 0.1.20
### Patch Changes
- [#1140](https://github.com/thirdweb-dev/js/pull/1140) [`16232de9`](https://github.com/thirdweb-dev/js/commit/16232de9eab9966e24e335929b2a3919346af265) Thanks [@kumaryash90](https://github.com/kumaryash90)! - Update chains
- [#1138](https://github.com/thirdweb-dev/js/pull/1138) [`645b0303`](https://github.com/thirdweb-dev/js/commit/645b0303cc1a9cbb0a0e9cbd67d11c3b865e4584) Thanks [@jcstein](https://github.com/jcstein)! - feat: create Taro Testnet
## 0.1.19
### Patch Changes
+5 -2
View File
@@ -11,20 +11,23 @@ export default {
"rpc": [
"https://gnosis.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://rpc.gnosischain.com",
"https://rpc.gnosis.gateway.fm",
"https://rpc.ankr.com/gnosis",
"https://gnosischain-rpc.gateway.pokt.network",
"https://gnosis-mainnet.public.blastapi.io",
"https://gnosis.api.onfinality.io/public",
"https://gnosis.blockpi.network/v1/rpc/public",
"https://web3endpoints.com/gnosischain-mainnet",
"wss://rpc.gnosischain.com/wss"
],
"faucets": [
"https://gnosisfaucet.com",
"https://faucet.gimlu.com/gnosis",
"https://stakely.io/faucet/gnosis-chain-xdai",
"https://faucet.prussia.dev/xdai"
],
"nativeCurrency": {
"name": "xDAI",
"symbol": "xDAI",
"symbol": "XDAI",
"decimals": 18
},
"infoURL": "https://docs.gnosischain.com",
+7 -6
View File
@@ -1,7 +1,7 @@
import type { Chain } from "../src/types";
export default {
"name": "Chiado Testnet",
"chain": "CHI",
"name": "Gnosis Chiado Testnet",
"chain": "GNO",
"icon": {
"url": "ipfs://bafybeidk4swpgdyqmpz6shd5onvpaujvwiwthrhypufnwr6xh3dausz2dm",
"width": 1800,
@@ -9,16 +9,17 @@ export default {
"format": "png"
},
"rpc": [
"https://chiado-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://gnosis-chiado-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://rpc.chiadochain.net",
"https://rpc.eu-central-2.gateway.fm/v3/gnosis/archival/chiado"
"https://rpc.chiado.gnosis.gateway.fm",
"wss://rpc.chiadochain.net/wss"
],
"faucets": [
"https://gnosisfaucet.com"
],
"nativeCurrency": {
"name": "Chiado xDAI",
"symbol": "xDAI",
"symbol": "XDAI",
"decimals": 18
},
"infoURL": "https://docs.gnosischain.com",
@@ -39,5 +40,5 @@ export default {
}
],
"testnet": true,
"slug": "chiado-testnet"
"slug": "gnosis-chiado-testnet"
} as const satisfies Chain;
+40
View File
@@ -0,0 +1,40 @@
import type { Chain } from "../src/types";
export default {
"name": "Siberium Test Network",
"chain": "SBR",
"rpc": [
"https://siberium-test-network.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://rpc.test.siberium.net"
],
"faucets": [],
"nativeCurrency": {
"name": "TestSIBR",
"symbol": "SIBR",
"decimals": 18
},
"infoURL": "https://siberium.net",
"shortName": "testsbr",
"chainId": 111000,
"networkId": 111000,
"icon": {
"url": "ipfs://QmYeMdWDZ1iaBFeSPorRyPi7RuSXTdDKTgW3rfnUf3W5ne",
"width": 512,
"height": 512,
"format": "svg"
},
"explorers": [
{
"name": "Siberium Testnet Explorer - blockscout",
"url": "https://explorer.test.siberium.net",
"icon": {
"url": "ipfs://QmYeMdWDZ1iaBFeSPorRyPi7RuSXTdDKTgW3rfnUf3W5ne",
"width": 512,
"height": 512,
"format": "svg"
},
"standard": "EIP3091"
}
],
"testnet": true,
"slug": "siberium-test-network"
} as const satisfies Chain;
+28
View File
@@ -0,0 +1,28 @@
import type { Chain } from "../src/types";
export default {
"name": "Living Assets Mainnet",
"chain": "LAS",
"icon": {
"url": "ipfs://QmRidubY7BVwC737BQwGEttenP1npAXN7ZNryktE416uUW",
"width": 500,
"height": 500,
"format": "jpg"
},
"rpc": [
"https://living-assets.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://beta.mainnet.livingassets.io/rpc",
"https://gamma.mainnet.livingassets.io/rpc"
],
"faucets": [],
"nativeCurrency": {
"name": "LAS",
"symbol": "LAS",
"decimals": 18
},
"infoURL": "https://dev.livingassets.io/",
"shortName": "LAS",
"chainId": 1440,
"networkId": 1440,
"testnet": false,
"slug": "living-assets"
} as const satisfies Chain;
+29
View File
@@ -0,0 +1,29 @@
import type { Chain } from "../src/types";
export default {
"name": "ChainX-EVM",
"chain": "ChainX",
"rpc": [
"https://chainx-evm.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://mainnet.chainx.org/rpc",
"https://mainnet2.chainx.org/rpc"
],
"faucets": [],
"nativeCurrency": {
"name": "BTC",
"symbol": "BTC",
"decimals": 18
},
"infoURL": "https://chainx.org",
"shortName": "chainx",
"chainId": 1501,
"networkId": 1501,
"explorers": [
{
"name": "chainx-evm scan",
"url": "https://evm.chainx.org",
"standard": "none"
}
],
"testnet": false,
"slug": "chainx-evm"
} as const satisfies Chain;
+36
View File
@@ -0,0 +1,36 @@
import type { Chain } from "../src/types";
export default {
"name": "Taro Testnet",
"chain": "gETH",
"shortName": "Taro",
"chainId": 1582,
"testnet": true,
"icon": {
"format": "svg",
"url": "ipfs://bafybeibfpls2ealp4e5fdeoxessfjjkldgjnrcx2erph7524pg7alskk6a/1f9cb.svg",
"width": 512,
"height": 512
},
"rpc": [
"https://taro-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://taro-testnet.calderachain.xyz/http"
],
"nativeCurrency": {
"decimals": 18,
"name": "Ether",
"symbol": "gETH"
},
"explorers": [
{
"url": "https://explorer.tarotestnet.com",
"name": "Taro Testnet Explorer",
"standard": "EIP3091"
}
],
"faucets": [
"https://tarotestnet.com"
],
"infoURL": "https://tarotestnet.com",
"networkId": 1582,
"slug": "taro-testnet"
} as const satisfies Chain;
-34
View File
@@ -1,34 +0,0 @@
import type { Chain } from "../src/types";
export default {
"name": "Taiko (Alpha-2 Testnet)",
"chain": "ETH",
"icon": {
"url": "ipfs://QmWMUDmNHzCtism9dYK1JooerZJ4da6kGt67HAQmLiEykc",
"width": 1001,
"height": 1001,
"format": "png"
},
"rpc": [
"https://taiko-alpha-2-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://rpc.a2.taiko.xyz"
],
"faucets": [],
"nativeCurrency": {
"name": "Ether",
"symbol": "ETH",
"decimals": 18
},
"infoURL": "https://taiko.xyz",
"shortName": "taiko-a2",
"chainId": 167004,
"networkId": 167004,
"explorers": [
{
"name": "blockscout",
"url": "https://explorer.a2.taiko.xyz",
"standard": "EIP3091"
}
],
"testnet": true,
"slug": "taiko-alpha-2-testnet"
} as const satisfies Chain;
+35
View File
@@ -0,0 +1,35 @@
import type { Chain } from "../src/types";
export default {
"name": "Taiko (Alpha-3 Testnet)",
"chain": "ETH",
"status": "active",
"icon": {
"url": "ipfs://QmcHdmVr5VRUJq13jnM6tgah5Ge7hn3Dm14eY6vwivJ5ui",
"width": 288,
"height": 258,
"format": "png"
},
"rpc": [
"https://taiko-alpha-3-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://rpc.test.taiko.xyz"
],
"faucets": [],
"nativeCurrency": {
"name": "Ether",
"symbol": "ETH",
"decimals": 18
},
"infoURL": "https://taiko.xyz",
"shortName": "taiko-a3",
"chainId": 167005,
"networkId": 167005,
"explorers": [
{
"name": "blockscout",
"url": "https://explorer.test.taiko.xyz",
"standard": "EIP3091"
}
],
"testnet": true,
"slug": "taiko-alpha-3-testnet"
} as const satisfies Chain;
+36
View File
@@ -0,0 +1,36 @@
import type { Chain } from "../src/types";
export default {
"name": "WhiteBIT Network Testnet",
"chain": "WBT",
"rpc": [
"https://whitebit-network-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://rpc-testnet.whitebit.network"
],
"faucets": [
"https://explorer.whitebit.network/testnet/faucet"
],
"nativeCurrency": {
"name": "WhiteBIT Coin",
"symbol": "WBT",
"decimals": 18
},
"infoURL": "https://whitebit.com/wbt",
"shortName": "twbt",
"chainId": 2625,
"networkId": 2625,
"icon": {
"url": "ipfs://QmQqAAn2F98TH5ouRyvReKxQdaGKjE7WJQPEPW6mFFVXUT",
"width": 32,
"height": 32,
"format": "svg"
},
"explorers": [
{
"name": "wb-explorer-testnet",
"url": "https://explorer.whitebit.network/testnet",
"standard": "EIP3091"
}
],
"testnet": true,
"slug": "whitebit-network-testnet"
} as const satisfies Chain;
-37
View File
@@ -1,37 +0,0 @@
import type { Chain } from "../src/types";
export default {
"name": "Optimism on Gnosis",
"chain": "OGC",
"rpc": [
"https://optimism-on-gnosis.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://optimism.gnosischain.com",
"wss://optimism.gnosischain.com/wss"
],
"faucets": [
"https://faucet.gimlu.com/gnosis"
],
"nativeCurrency": {
"name": "xDAI",
"symbol": "xDAI",
"decimals": 18
},
"infoURL": "https://www.xdaichain.com/for-developers/optimism-optimistic-rollups-on-gc",
"shortName": "ogc",
"chainId": 300,
"networkId": 300,
"explorers": [
{
"name": "blockscout",
"url": "https://blockscout.com/xdai/optimism",
"icon": {
"url": "ipfs://bafybeifu5tpui7dk5cjoo54kde7pmuthvnl7sdykobuarsxgu7t2izurnq",
"width": 512,
"height": 512,
"format": "png"
},
"standard": "EIP3091"
}
],
"testnet": false,
"slug": "optimism-on-gnosis"
} as const satisfies Chain;
-59
View File
@@ -1,59 +0,0 @@
import type { Chain } from "../src/types";
export default {
"name": "Filecoin - Hyperspace testnet",
"chain": "FIL",
"icon": {
"url": "ipfs://QmS9r9XQkMHVomWcSBNDkKkz9n87h9bH9ssabeiKZtANoU",
"width": 1000,
"height": 1000,
"format": "png"
},
"rpc": [
"https://filecoin-hyperspace-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://api.hyperspace.node.glif.io/rpc/v1",
"https://rpc.ankr.com/filecoin_testnet",
"https://filecoin-hyperspace.chainstacklabs.com/rpc/v1"
],
"faucets": [
"https://hyperspace.yoga/#faucet"
],
"nativeCurrency": {
"name": "testnet filecoin",
"symbol": "tFIL",
"decimals": 18
},
"infoURL": "https://filecoin.io",
"shortName": "filecoin-hyperspace",
"chainId": 3141,
"networkId": 3141,
"slip44": 1,
"explorers": [
{
"name": "Filfox - Hyperspace",
"url": "https://hyperspace.filfox.info/en",
"standard": "none"
},
{
"name": "Glif Explorer - Hyperspace",
"url": "https://explorer.glif.io/?network=hyperspace",
"standard": "none"
},
{
"name": "Beryx",
"url": "https://beryx.zondax.ch",
"standard": "none"
},
{
"name": "Dev.storage",
"url": "https://dev.storage",
"standard": "none"
},
{
"name": "Filscan - Hyperspace",
"url": "https://hyperspace.filscan.io",
"standard": "none"
}
],
"testnet": true,
"slug": "filecoin-hyperspace-testnet"
} as const satisfies Chain;
-31
View File
@@ -1,31 +0,0 @@
import type { Chain } from "../src/types";
export default {
"name": "Filecoin - Wallaby testnet",
"chain": "FIL",
"icon": {
"url": "ipfs://QmS9r9XQkMHVomWcSBNDkKkz9n87h9bH9ssabeiKZtANoU",
"width": 1000,
"height": 1000,
"format": "png"
},
"rpc": [
"https://filecoin-wallaby-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://wallaby.node.glif.io/rpc/v1"
],
"faucets": [
"https://wallaby.yoga/#faucet"
],
"nativeCurrency": {
"name": "testnet filecoin",
"symbol": "tFIL",
"decimals": 18
},
"infoURL": "https://filecoin.io",
"shortName": "filecoin-wallaby",
"chainId": 31415,
"networkId": 31415,
"slip44": 1,
"explorers": [],
"testnet": true,
"slug": "filecoin-wallaby-testnet"
} as const satisfies Chain;
+14 -1
View File
@@ -10,7 +10,10 @@ export default {
},
"rpc": [
"https://filecoin-calibration-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://api.calibration.node.glif.io/rpc/v1"
"https://api.calibration.node.glif.io/rpc/v1",
"https://rpc.ankr.com/filecoin_testnet",
"https://filecoin-calibration.chainstacklabs.com/rpc/v1",
"https://filecoin-calibration.chainup.net/rpc/v1"
],
"faucets": [
"https://faucet.calibration.fildev.network/"
@@ -40,6 +43,16 @@ export default {
"name": "Filfox - Calibration",
"url": "https://calibration.filfox.info",
"standard": "none"
},
{
"name": "Glif Explorer - Calibration",
"url": "https://explorer.glif.io/?network=calibration",
"standard": "none"
},
{
"name": "Beryx",
"url": "https://beryx.zondax.ch",
"standard": "none"
}
],
"testnet": true,
+48
View File
@@ -0,0 +1,48 @@
import type { Chain } from "../src/types";
export default {
"name": "Aves Testnet",
"chain": "AVST",
"rpc": [
"https://aves-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://test.rpc.avescoin.io"
],
"faucets": [],
"nativeCurrency": {
"name": "AvesT",
"symbol": "AVST",
"decimals": 18
},
"features": [
{
"name": "EIP155"
},
{
"name": "EIP1559"
}
],
"infoURL": "https://ethereum.org",
"shortName": "avst",
"chainId": 333331,
"networkId": 333331,
"icon": {
"url": "ipfs://QmeKQVv2QneHaaggw2NfpZ7DGMdjVhPywTdse5RzCs4oGn",
"width": 232,
"height": 232,
"format": "png"
},
"explorers": [
{
"name": "avescan",
"url": "https://testnet.avescoin.io",
"icon": {
"url": "ipfs://QmeKQVv2QneHaaggw2NfpZ7DGMdjVhPywTdse5RzCs4oGn",
"width": 232,
"height": 232,
"format": "png"
},
"standard": "EIP3091"
}
],
"testnet": true,
"slug": "aves-testnet"
} as const satisfies Chain;
+31 -22
View File
@@ -1,37 +1,46 @@
import type { Chain } from "../src/types";
export default {
"name": "Kovan",
"title": "Ethereum Testnet Kovan",
"chain": "ETH",
"name": "LUKSO Mainnet",
"chain": "LUKSO",
"icon": {
"url": "ipfs://Qmeg9sFF5tAGi6MCx7YjtVHW6a23zqvHRK1xwzSdp9iE7z",
"width": 512,
"height": 512,
"format": "png"
},
"rpc": [
"https://kovan.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://kovan.poa.network",
"http://kovan.poa.network:8545",
"https://kovan.infura.io/v3/${INFURA_API_KEY}",
"wss://kovan.infura.io/ws/v3/${INFURA_API_KEY}",
"ws://kovan.poa.network:8546"
],
"faucets": [
"http://fauceth.komputing.org?chain=42&address=${ADDRESS}",
"https://faucet.kovan.network",
"https://gitter.im/kovan-testnet/faucet"
"https://lukso.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://rpc.mainnet.lukso.network",
"wss://ws-rpc.mainnet.lukso.network"
],
"faucets": [],
"nativeCurrency": {
"name": "Kovan Ether",
"symbol": "ETH",
"name": "LUKSO",
"symbol": "LYX",
"decimals": 18
},
"explorers": [
{
"name": "etherscan",
"url": "https://kovan.etherscan.io",
"name": "Blockscout",
"url": "https://explorer.execution.mainnet.lukso.network",
"standard": "EIP3091"
}
],
"infoURL": "https://kovan-testnet.github.io/website",
"shortName": "kov",
"infoURL": "https://lukso.network",
"shortName": "lukso",
"chainId": 42,
"networkId": 42,
"testnet": true,
"slug": "kovan"
"features": [
{
"name": "EIP155"
},
{
"name": "EIP1559"
}
],
"redFlags": [
"reusedChainId"
],
"testnet": false,
"slug": "lukso"
} as const satisfies Chain;
+45
View File
@@ -0,0 +1,45 @@
import type { Chain } from "../src/types";
export default {
"name": "LUKSO Testnet",
"chain": "LUKSO Testnet",
"icon": {
"url": "ipfs://Qmeg9sFF5tAGi6MCx7YjtVHW6a23zqvHRK1xwzSdp9iE7z",
"width": 512,
"height": 512,
"format": "png"
},
"rpc": [
"https://lukso-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://rpc.testnet.lukso.network",
"wss://ws-rpc.testnet.lukso.network"
],
"faucets": [
"https://faucet.testnet.lukso.network"
],
"nativeCurrency": {
"name": "TestLYX",
"symbol": "LYXt",
"decimals": 18
},
"explorers": [
{
"name": "Blockscout",
"url": "https://explorer.execution.testnet.lukso.network",
"standard": "none"
}
],
"infoURL": "https://lukso.network",
"shortName": "lukso-testnet",
"chainId": 4201,
"networkId": 4201,
"features": [
{
"name": "EIP155"
},
{
"name": "EIP1559"
}
],
"testnet": true,
"slug": "lukso-testnet"
} as const satisfies Chain;
+21
View File
@@ -0,0 +1,21 @@
import type { Chain } from "../src/types";
export default {
"name": "Patex Sepolia Testnet",
"chain": "ETH",
"rpc": [
"https://patex-sepolia-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://test-rpc.patex.io/"
],
"faucets": [],
"nativeCurrency": {
"name": "Sepolia Ether",
"symbol": "ETH",
"decimals": 18
},
"infoURL": "https://patex.io/",
"shortName": "psep",
"chainId": 471100,
"networkId": 471100,
"testnet": true,
"slug": "patex-sepolia-testnet"
} as const satisfies Chain;
+2 -2
View File
@@ -8,8 +8,8 @@ export default {
],
"faucets": [],
"nativeCurrency": {
"name": "BitDAO",
"symbol": "BIT",
"name": "Mantle",
"symbol": "MNT",
"decimals": 18
},
"infoURL": "https://mantle.xyz",
+2 -2
View File
@@ -10,8 +10,8 @@ export default {
"https://faucet.testnet.mantle.xyz"
],
"nativeCurrency": {
"name": "Testnet BitDAO",
"symbol": "BIT",
"name": "Testnet Mantle",
"symbol": "MNT",
"decimals": 18
},
"infoURL": "https://mantle.xyz",
+2
View File
@@ -5,6 +5,8 @@ export default {
"rpc": [
"https://syscoin.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://rpc.syscoin.org",
"https://rpc.ankr.com/syscoin/${ANKR_API_KEY}",
"https://syscoin.public-rpc.com",
"wss://rpc.syscoin.org/wss"
],
"faucets": [
+31
View File
@@ -0,0 +1,31 @@
import type { Chain } from "../src/types";
export default {
"name": "Rollux Mainnet",
"chain": "SYS",
"rpc": [
"https://rollux.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://rpc.rollux.com",
"wss://rpc.rollux.com/wss"
],
"faucets": [
"https://rollux.id/faucetapp"
],
"nativeCurrency": {
"name": "Syscoin",
"symbol": "SYS",
"decimals": 18
},
"infoURL": "https://rollux.com",
"shortName": "sys-rollux",
"chainId": 570,
"networkId": 570,
"explorers": [
{
"name": "Rollux Explorer",
"url": "https://explorer.rollux.com",
"standard": "EIP3091"
}
],
"testnet": false,
"slug": "rollux"
} as const satisfies Chain;
+11 -8
View File
@@ -1,29 +1,32 @@
import type { Chain } from "../src/types";
export default {
"name": "Syscoin Rollux Testnet",
"name": "Rollux Testnet",
"chain": "SYS",
"rpc": [
"https://syscoin-rollux-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://rollux-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://rpc-tanenbaum.rollux.com",
"https://rpc.ankr.com/rollux_testnet/${ANKR_API_KEY}",
"wss://rpc-tanenbaum.rollux.com/wss"
],
"faucets": [],
"faucets": [
"https://rollux.id/faucetapp"
],
"nativeCurrency": {
"name": "Rollux Testnet Syscoin",
"symbol": "tSYS",
"name": "Testnet Syscoin",
"symbol": "TSYS",
"decimals": 18
},
"infoURL": "https://syscoin.org",
"infoURL": "https://rollux.com",
"shortName": "tsys-rollux",
"chainId": 57000,
"networkId": 57000,
"explorers": [
{
"name": "Syscoin Rollux Testnet Explorer",
"name": "Rollux Testnet Explorer",
"url": "https://rollux.tanenbaum.io",
"standard": "EIP3091"
}
],
"testnet": true,
"slug": "syscoin-rollux-testnet"
"slug": "rollux-testnet"
} as const satisfies Chain;
+1
View File
@@ -4,6 +4,7 @@ export default {
"chain": "ASTR",
"rpc": [
"https://astar.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://evm.astar.network",
"https://rpc.astar.network:8545"
],
"faucets": [],
+39
View File
@@ -0,0 +1,39 @@
import type { Chain } from "../src/types";
export default {
"name": "UPTN Testnet",
"chain": "UPTN",
"icon": {
"url": "ipfs://Qma6cGPCDcJPFxy5KQaMBrLtuVQiqeLncXVybcBoQuhai5",
"width": 128,
"height": 128,
"format": "png"
},
"rpc": [
"https://uptn-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://node-api.alp.uptn.io/v1/ext/rpc"
],
"features": [
{
"name": "EIP1559"
}
],
"faucets": [],
"nativeCurrency": {
"name": "UPTN",
"symbol": "UPTN",
"decimals": 18
},
"infoURL": "https://uptn.io",
"shortName": "UPTN-TEST",
"chainId": 6118,
"networkId": 6118,
"explorers": [
{
"name": "UPTN Testnet Explorer",
"url": "https://testnet.explorer.uptn.io",
"standard": "EIP3091"
}
],
"testnet": true,
"slug": "uptn-testnet"
} as const satisfies Chain;
+39
View File
@@ -0,0 +1,39 @@
import type { Chain } from "../src/types";
export default {
"name": "UPTN",
"chain": "UPTN",
"icon": {
"url": "ipfs://Qma6cGPCDcJPFxy5KQaMBrLtuVQiqeLncXVybcBoQuhai5",
"width": 128,
"height": 128,
"format": "png"
},
"rpc": [
"https://uptn.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://node-api.uptn.io/v1/ext/rpc"
],
"features": [
{
"name": "EIP1559"
}
],
"faucets": [],
"nativeCurrency": {
"name": "UPTN",
"symbol": "UPTN",
"decimals": 18
},
"infoURL": "https://uptn.io",
"shortName": "UPTN",
"chainId": 6119,
"networkId": 6119,
"explorers": [
{
"name": "UPTN Explorer",
"url": "https://explorer.uptn.io",
"standard": "EIP3091"
}
],
"testnet": false,
"slug": "uptn"
} as const satisfies Chain;
+36
View File
@@ -0,0 +1,36 @@
import type { Chain } from "../src/types";
export default {
"name": "MAAL Sharia Chain",
"chain": "MAAL",
"icon": {
"url": "ipfs://bafkreiexfqfe2x4impvwhra3xxa5eb25gv25zi3kkaoatdnld7wbxdzf2a",
"width": 512,
"height": 512,
"format": "png"
},
"rpc": [
"https://maal-sharia-chain.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://node1-mainnet.maalscan.io/",
"https://node2-mainnet.maalscan.io/",
"https://node3-mainnet.maalscan.io/"
],
"faucets": [],
"nativeCurrency": {
"name": "MAAL",
"symbol": "MAAL",
"decimals": 18
},
"infoURL": "https://www.maalblockchain.com/",
"shortName": "maal",
"chainId": 786,
"networkId": 786,
"explorers": [
{
"name": "maalscan",
"url": "https://maalscan.io",
"standard": "EIP3091"
}
],
"testnet": false,
"slug": "maal-sharia-chain"
} as const satisfies Chain;
+21
View File
@@ -0,0 +1,21 @@
import type { Chain } from "../src/types";
export default {
"name": "Patex",
"chain": "ETH",
"rpc": [
"https://patex.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://rpc.patex.io/"
],
"faucets": [],
"nativeCurrency": {
"name": "Ether",
"symbol": "ETH",
"decimals": 18
},
"infoURL": "https://patex.io/",
"shortName": "peth",
"chainId": 789,
"networkId": 789,
"testnet": false,
"slug": "patex"
} as const satisfies Chain;
+37
View File
@@ -0,0 +1,37 @@
import type { Chain } from "../src/types";
export default {
"name": "Nautilus Chain",
"title": "Nautilus Trition Testnet",
"chain": "ETH",
"icon": {
"url": "ipfs://QmNutSgM7n6aJPPDiofe9Dm1epy1RcYTMvugukLUK2vmPM",
"width": 500,
"height": 500,
"format": "png"
},
"rpc": [
"https://nautilus-chain.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://triton.api.nautchain.xyz"
],
"faucets": [
"https://faucet.eclipse.builders"
],
"nativeCurrency": {
"name": "Nautilus Zebec Testnet Tokens",
"symbol": "tZBC",
"decimals": 18
},
"infoURL": "https://docs.nautchain.xyz",
"shortName": "NAUT",
"chainId": 91002,
"networkId": 91002,
"explorers": [
{
"name": "Nautscan",
"url": "https://triton.nautscan.com",
"standard": "EIP3091"
}
],
"testnet": true,
"slug": "nautilus-chain"
} as const satisfies Chain;
+14 -9
View File
@@ -1,21 +1,26 @@
import type { Chain } from "../src/types";
export default {
"name": "Wanchain Testnet",
"chain": "WAN",
"name": "Zora Testnet",
"chain": "ETH",
"rpc": [
"https://wanchain-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://gwan-ssl.wandevs.org:46891/"
"https://zora-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://testnet.rpc.zora.co/"
],
"faucets": [],
"nativeCurrency": {
"name": "Wancoin",
"symbol": "WAN",
"name": "Ether",
"symbol": "GETH",
"decimals": 18
},
"infoURL": "https://testnet.wanscan.org",
"shortName": "twan",
"icon": {
"url": "ipfs://QmZ6qaRwTPFEZUspwMUjaxC6KhmzcELdRQcQzS3P72Dzts/Vector.svg",
"height": 512,
"width": 512,
"format": "svg"
},
"shortName": "Zora",
"chainId": 999,
"networkId": 999,
"testnet": true,
"slug": "wanchain-testnet"
"slug": "zora-testnet"
} as const satisfies Chain;
+33
View File
@@ -0,0 +1,33 @@
// @ts-check
/** @typedef { import("../../src/types").Chain } Chain */
/** @type {Omit<Chain, "slug">} */
export default {
name: "Taro Testnet",
chain: "gETH",
shortName: "Taro",
chainId: 1582,
testnet: true,
icon: {
format: "svg",
url: "ipfs://bafybeibfpls2ealp4e5fdeoxessfjjkldgjnrcx2erph7524pg7alskk6a/1f9cb.svg",
width: 512,
height: 512,
},
rpc: ["https://taro-testnet.calderachain.xyz/http"],
nativeCurrency: {
decimals: 18,
name: "Ether",
symbol: "gETH",
},
explorers: [
{
url: "https://explorer.tarotestnet.com",
name: "Taro Testnet Explorer",
standard: "EIP3091",
},
],
faucets: ["https://tarotestnet.com"],
infoURL: "https://tarotestnet.com",
networkId: 1582,
};
+25
View File
@@ -0,0 +1,25 @@
// @ts-check
/** @typedef { import("../../src/types").Chain } Chain */
/** @type {Omit<Chain, "slug">} */
export default {
name: "Zora Testnet",
chain: "ETH",
rpc: ["https://testnet.rpc.zora.co/"],
faucets: [],
nativeCurrency: {
name: "Ether",
symbol: "GETH",
decimals: 18,
},
icon: {
url: "ipfs://QmZ6qaRwTPFEZUspwMUjaxC6KhmzcELdRQcQzS3P72Dzts/Vector.svg",
height: 512,
width: 512,
format: "svg",
},
shortName: "Zora",
chainId: 999,
networkId: 999,
testnet: true,
};
+7
View File
@@ -0,0 +1,7 @@
// @ts-check
/** @typedef { import("../../src/types").Chain } Chain */
/** @type {Partial<Chain>} */
export default {
rpc: ["https://evm.astar.network"],
};
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/chains",
"version": "0.1.19",
"version": "0.1.20",
"main": "dist/thirdweb-dev-chains.cjs.js",
"module": "dist/thirdweb-dev-chains.esm.js",
"browser": {
@@ -54,6 +54,8 @@ for (const file of additionalChainsFiles) {
const additionalChain = await import(
path.join("file://", additionalChainsDir, file)
);
chains = chains.filter((c) => c.chainId !== additionalChain.default.chainId);
chains.push(additionalChain.default);
}
File diff suppressed because one or more lines are too long
+23
View File
@@ -1,5 +1,28 @@
# thirdweb
## 0.10.22
### Patch Changes
- Updated dependencies [[`3bf7f375`](https://github.com/thirdweb-dev/js/commit/3bf7f375933cbd7dd8c682a66e8c67bbcb268bf7), [`16232de9`](https://github.com/thirdweb-dev/js/commit/16232de9eab9966e24e335929b2a3919346af265), [`8687d6ac`](https://github.com/thirdweb-dev/js/commit/8687d6ac3a363eae63eeb1959a953cbcd282d353), [`645b0303`](https://github.com/thirdweb-dev/js/commit/645b0303cc1a9cbb0a0e9cbd67d11c3b865e4584), [`522453fd`](https://github.com/thirdweb-dev/js/commit/522453fd568b8c350141a96f9f1c6d5a3ef74493), [`6803c3e9`](https://github.com/thirdweb-dev/js/commit/6803c3e97ca74eed19cd90095afde25b02150d51), [`56f85e57`](https://github.com/thirdweb-dev/js/commit/56f85e57df84bfa93e3230639c95d12466f8aec7), [`6a91b6a0`](https://github.com/thirdweb-dev/js/commit/6a91b6a0253bab5914d4ebdad951dd1c5d141fbc), [`a5f16b6d`](https://github.com/thirdweb-dev/js/commit/a5f16b6dc50b37920a6e5210b60aa6a1682ceb63), [`b6728603`](https://github.com/thirdweb-dev/js/commit/b6728603972ccd6c95108b25e8562807f0f95e19), [`ed47fd53`](https://github.com/thirdweb-dev/js/commit/ed47fd5310d11323080d984bca18a96fdef3a977)]:
- @thirdweb-dev/sdk@3.10.21
- @thirdweb-dev/chains@0.1.20
## 0.10.21
### Patch Changes
- Updated dependencies [[`ce36322b`](https://github.com/thirdweb-dev/js/commit/ce36322b383af73905894b73f9409a146359ffb0), [`c60658ed`](https://github.com/thirdweb-dev/js/commit/c60658ed8c94867cca831b0d5535006da5b40aa6), [`aa9e952c`](https://github.com/thirdweb-dev/js/commit/aa9e952cb519a47ed112d2905b1f3787863035b6), [`564eaccf`](https://github.com/thirdweb-dev/js/commit/564eaccf480a81f36db43c782392595a5021e5ac), [`6aee0413`](https://github.com/thirdweb-dev/js/commit/6aee0413439b9ca408879bbb3c38c538c89d01af), [`e93aa70e`](https://github.com/thirdweb-dev/js/commit/e93aa70ef0093a2526404e11b7ddae8fb98c213b), [`51bbd3d1`](https://github.com/thirdweb-dev/js/commit/51bbd3d1bccbb92a1405ea50f6c178c091a90f20)]:
- @thirdweb-dev/sdk@3.10.20
## 0.10.20
### Patch Changes
- Updated dependencies [[`23d90b3e`](https://github.com/thirdweb-dev/js/commit/23d90b3e779a5bfdb7058b8c51349d9c278fcbce), [`cc56037e`](https://github.com/thirdweb-dev/js/commit/cc56037e64560b9e0fc16eb0ac7cc2e47e2c9fdf), [`67450789`](https://github.com/thirdweb-dev/js/commit/67450789473b6008b86453ee4f4c7b99461223a6)]:
- @thirdweb-dev/sdk@3.10.19
- @thirdweb-dev/storage@1.1.4
## 0.10.19
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "thirdweb",
"main": "dist/cli/index.js",
"version": "0.10.19",
"version": "0.10.22",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/cli",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
+6
View File
@@ -1,5 +1,11 @@
# @thirdweb-dev/contracts-js
## 1.3.5
### Patch Changes
- [#1095](https://github.com/thirdweb-dev/js/pull/1095) [`564eaccf`](https://github.com/thirdweb-dev/js/commit/564eaccf480a81f36db43c782392595a5021e5ac) Thanks [@nkrishang](https://github.com/nkrishang)! - Add SmartWalletFactory extension detection and logic
## 1.3.4
### Patch Changes
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/contracts-js",
"version": "1.3.4",
"version": "1.3.5",
"main": "dist/thirdweb-dev-contracts-js.cjs.js",
"module": "dist/thirdweb-dev-contracts-js.esm.js",
"browser": {
@@ -10,7 +10,7 @@
"license": "Apache-2.0",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/contracts-js",
"dependencies": {
"@thirdweb-dev/contracts": "3.4.7-0"
"@thirdweb-dev/contracts": "3.5.5"
},
"devDependencies": {
"@babel/preset-env": "^7.18.10",
+44
View File
@@ -1,5 +1,49 @@
# @thirdweb-dev/react-core
## 3.13.1
### Patch Changes
- [#1145](https://github.com/thirdweb-dev/js/pull/1145) [`6a194262`](https://github.com/thirdweb-dev/js/commit/6a19426200297b8da158c7d860d31efcc8c15822) Thanks [@nachoiacovino](https://github.com/nachoiacovino)! - Add hook to check if a smart wallet has been deployed for the given admin
- [#1123](https://github.com/thirdweb-dev/js/pull/1123) [`54cfd6d8`](https://github.com/thirdweb-dev/js/commit/54cfd6d8916c42d87b6aa438e607ce525766b686) Thanks [@nachoiacovino](https://github.com/nachoiacovino)! - Update useCreateSmartWallet
- [#1136](https://github.com/thirdweb-dev/js/pull/1136) [`9a015a23`](https://github.com/thirdweb-dev/js/commit/9a015a23cde09c8ba6c36593a84303ffe409a79a) Thanks [@MananTank](https://github.com/MananTank)! - Logout user on wallet account switch
- [#1119](https://github.com/thirdweb-dev/js/pull/1119) [`0cba69ca`](https://github.com/thirdweb-dev/js/commit/0cba69ca40a8cf6f106344247d0082212cd169da) Thanks [@nachoiacovino](https://github.com/nachoiacovino)! - Export smart wallet factory hooks
- [#1146](https://github.com/thirdweb-dev/js/pull/1146) [`e32faeb5`](https://github.com/thirdweb-dev/js/commit/e32faeb57a5c2193c40cb6129fab92b84069b12d) Thanks [@nachoiacovino](https://github.com/nachoiacovino)! - Fix return type for useIsSmartWalletDeployed
- [#1144](https://github.com/thirdweb-dev/js/pull/1144) [`9ce3eb6a`](https://github.com/thirdweb-dev/js/commit/9ce3eb6aad957aff38fb4a25383ed17ff58e988f) Thanks [@MananTank](https://github.com/MananTank)! - Remove WalletConfig.config object from wallets
- Updated dependencies [[`2a443365`](https://github.com/thirdweb-dev/js/commit/2a443365bdc3d47d0f41fc895f70256dcde423f5), [`3bf7f375`](https://github.com/thirdweb-dev/js/commit/3bf7f375933cbd7dd8c682a66e8c67bbcb268bf7), [`16232de9`](https://github.com/thirdweb-dev/js/commit/16232de9eab9966e24e335929b2a3919346af265), [`8687d6ac`](https://github.com/thirdweb-dev/js/commit/8687d6ac3a363eae63eeb1959a953cbcd282d353), [`645b0303`](https://github.com/thirdweb-dev/js/commit/645b0303cc1a9cbb0a0e9cbd67d11c3b865e4584), [`522453fd`](https://github.com/thirdweb-dev/js/commit/522453fd568b8c350141a96f9f1c6d5a3ef74493), [`6803c3e9`](https://github.com/thirdweb-dev/js/commit/6803c3e97ca74eed19cd90095afde25b02150d51), [`56f85e57`](https://github.com/thirdweb-dev/js/commit/56f85e57df84bfa93e3230639c95d12466f8aec7), [`197a6838`](https://github.com/thirdweb-dev/js/commit/197a6838f69ae8b9ad46524e7c469fc757d0a2cb), [`6a91b6a0`](https://github.com/thirdweb-dev/js/commit/6a91b6a0253bab5914d4ebdad951dd1c5d141fbc), [`a5f16b6d`](https://github.com/thirdweb-dev/js/commit/a5f16b6dc50b37920a6e5210b60aa6a1682ceb63), [`b6728603`](https://github.com/thirdweb-dev/js/commit/b6728603972ccd6c95108b25e8562807f0f95e19), [`ed47fd53`](https://github.com/thirdweb-dev/js/commit/ed47fd5310d11323080d984bca18a96fdef3a977)]:
- @thirdweb-dev/wallets@0.2.26
- @thirdweb-dev/sdk@3.10.21
- @thirdweb-dev/chains@0.1.20
## 3.13.0
### Minor Changes
- [#1114](https://github.com/thirdweb-dev/js/pull/1114) [`2283e71a`](https://github.com/thirdweb-dev/js/commit/2283e71acaaf3d15eb2d6121682f1d2a81eec4f3) Thanks [@adam-maj](https://github.com/adam-maj)! - Switch to server-side payload generation
### Patch Changes
- [#1111](https://github.com/thirdweb-dev/js/pull/1111) [`21627c03`](https://github.com/thirdweb-dev/js/commit/21627c03d1bb1658fee19b12d580faa6c7f048d9) Thanks [@adam-maj](https://github.com/adam-maj)! - Update expiration dates for auth
- Updated dependencies [[`ce36322b`](https://github.com/thirdweb-dev/js/commit/ce36322b383af73905894b73f9409a146359ffb0), [`c60658ed`](https://github.com/thirdweb-dev/js/commit/c60658ed8c94867cca831b0d5535006da5b40aa6), [`aa9e952c`](https://github.com/thirdweb-dev/js/commit/aa9e952cb519a47ed112d2905b1f3787863035b6), [`564eaccf`](https://github.com/thirdweb-dev/js/commit/564eaccf480a81f36db43c782392595a5021e5ac), [`6aee0413`](https://github.com/thirdweb-dev/js/commit/6aee0413439b9ca408879bbb3c38c538c89d01af), [`e93aa70e`](https://github.com/thirdweb-dev/js/commit/e93aa70ef0093a2526404e11b7ddae8fb98c213b), [`51bbd3d1`](https://github.com/thirdweb-dev/js/commit/51bbd3d1bccbb92a1405ea50f6c178c091a90f20), [`9b20fc9a`](https://github.com/thirdweb-dev/js/commit/9b20fc9ad2d303edc31f44fbd2ea3b4dcf35d11e)]:
- @thirdweb-dev/sdk@3.10.20
- @thirdweb-dev/wallets@0.2.25
## 3.12.4
### Patch Changes
- Updated dependencies [[`23d90b3e`](https://github.com/thirdweb-dev/js/commit/23d90b3e779a5bfdb7058b8c51349d9c278fcbce), [`cc56037e`](https://github.com/thirdweb-dev/js/commit/cc56037e64560b9e0fc16eb0ac7cc2e47e2c9fdf), [`67450789`](https://github.com/thirdweb-dev/js/commit/67450789473b6008b86453ee4f4c7b99461223a6)]:
- @thirdweb-dev/sdk@3.10.19
- @thirdweb-dev/storage@1.1.4
- @thirdweb-dev/wallets@0.2.24
## 3.12.3
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/react-core",
"version": "3.12.3",
"version": "3.13.1",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-core",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
@@ -1,4 +1,4 @@
import { ThirdwebAuthProvider } from "../../evm/contexts/thirdweb-auth";
import { ThirdwebAuthProvider } from "../../evm/contexts/ThirdwebAuthProvider";
import { useUpdateChainsWithApiKeys } from "../../evm/hooks/chain-hooks";
import { ThirdwebSDKProvider } from "../../evm/providers/thirdweb-sdk-provider";
import { ThirdwebSDKProviderProps } from "../../evm/providers/types";
@@ -42,26 +42,23 @@ type WalletConnectParams<I extends WalletInstance> = Parameters<
type ConnectionStatus = "unknown" | "connected" | "disconnected" | "connecting";
type ConnectFnArgs<
I extends WalletInstance,
Config extends Record<string, any> | undefined,
> =
type ConnectFnArgs<I extends WalletInstance> =
// if second argument is optional
undefined extends WalletConnectParams<I>
? [
wallet: WalletConfig<I, Config>,
wallet: WalletConfig<I>,
connectParams?: NonNullable<WalletConnectParams<I>>,
]
: // if second argument is required
[
wallet: WalletConfig<I, Config>,
wallet: WalletConfig<I>,
connectParams: NonNullable<WalletConnectParams<I>>,
];
// maps wallet instance to it's wallet config
const walletInstanceToConfig: Map<
WalletInstance,
WalletConfig<any, any>
WalletConfig<any>
> = new Map();
type ThirdwebWalletContextData = {
@@ -69,20 +66,12 @@ type ThirdwebWalletContextData = {
signer?: Signer;
activeWallet?: WalletInstance;
activeWalletConfig?: WalletConfig;
connect: <
I extends WalletInstance,
Config extends Record<string, any> | undefined = undefined,
>(
...args: ConnectFnArgs<I, Config>
) => Promise<I>;
connect: <I extends WalletInstance>(...args: ConnectFnArgs<I>) => Promise<I>;
disconnect: () => Promise<void>;
connectionStatus: ConnectionStatus;
setConnectionStatus: (status: ConnectionStatus) => void;
createWalletInstance: <
I extends WalletInstance,
Config extends Record<string, any> | undefined,
>(
Wallet: WalletConfig<I, Config>,
createWalletInstance: <I extends WalletInstance>(
Wallet: WalletConfig<I>,
) => I;
createdWalletInstance?: WalletInstance;
createWalletStorage: CreateAsyncStorage;
@@ -155,9 +144,7 @@ export function ThirdwebWalletProvider(
}, [props.chains, props.dAppMeta, props.activeChain, theme]);
const createWalletInstance = useCallback(
<I extends WalletInstance, Config extends Record<string, any> | undefined>(
walletConfig: WalletConfig<I, Config>,
): I => {
<I extends WalletInstance>(walletConfig: WalletConfig<I>): I => {
const walletInstance = walletConfig.create(walletParams);
if (walletInstance.walletId === walletIds.magicLink) {
// NOTE: removing this if statement causes the component to re-render
@@ -314,14 +301,7 @@ export function ThirdwebWalletProvider(
const personalWalletInfo = walletInfo.connectParams?.personalWallet;
if (personalWalletInfo) {
type Config = {
personalWallets: WalletConfig[];
};
const personalWallets =
"config" in walletObj
? (walletObj.config as Config).personalWallets
: [];
const personalWallets = walletObj.personalWallets || [];
const personalWalleObj = personalWallets.find(
(W) => W.id === personalWalletInfo.walletId,
@@ -379,12 +359,7 @@ export function ThirdwebWalletProvider(
]);
const connectWallet = useCallback(
async <
I extends WalletInstance,
Config extends Record<string, any> | undefined = undefined,
>(
...args: ConnectFnArgs<I, Config>
): Promise<I> => {
async <I extends WalletInstance>(...args: ConnectFnArgs<I>): Promise<I> => {
const [WalletObj, connectParams] = args;
const _connectedParams = {
+18 -21
View File
@@ -23,32 +23,32 @@ export type WalletClass<I extends WalletInstance = WalletInstance> = {
meta: (typeof AbstractClientWallet)["meta"];
};
export type WalletConfig<
I extends WalletInstance = WalletInstance,
Config extends Record<string, any> | undefined = undefined,
> = {
export type WalletConfig<I extends WalletInstance = WalletInstance> = {
id: string;
meta: (typeof AbstractClientWallet)["meta"];
create: (options: WalletOptions) => I;
/**
* UI for connecting wallet
*/
connectUI?: React.FC<ConnectUIProps<I, Config>>;
connectUI?: React.FC<ConnectUIProps<I>>;
/**
* UI for selecting wallet - this UI is rendered in the wallet selection screen
*/
selectUI?: React.FC<SelectUIProps<I, Config>>;
selectUI?: React.FC<SelectUIProps<I>>;
isInstalled?: () => boolean;
} & (Config extends undefined
? {}
: {
config: Config;
});
/**
* An array of `WalletConfig` that users can use as a personal wallet to connect to your wallet
*
* This is only required if your wallet requires a personal wallet to be connected such as a Safe Wallet or Smart Wallet
*
* providing the `personalWallets` ensures that autoconnect and ConnectWallet modal works properly for your wallet.
* * autoconnect will connect the last connected personal wallet first and then connect your wallet
* * ConnectWallet modal will reopen once the personal wallet is connected so that you can render UI for connecting your wallet as the next step
*/
personalWallets?: WalletConfig[];
};
export type ConnectUIProps<
I extends WalletInstance = WalletInstance,
Config extends Record<string, any> | undefined = undefined,
> = {
export type ConnectUIProps<I extends WalletInstance = WalletInstance> = {
/**
* close the connect wallet modal
* @param reset reset Connect Wallet Modal to initial state, so that if it's opened again, it will start from the wallet-selection screen
@@ -117,7 +117,7 @@ export type ConnectUIProps<
* }
* ```
*/
walletConfig: WalletConfig<I, Config>;
walletConfig: WalletConfig<I>;
/**
* selectionData passed from `selectUI`'s `onSelect` function
@@ -136,10 +136,7 @@ export type ConnectUIProps<
supportedWallets: WalletConfig[];
};
export type SelectUIProps<
I extends WalletInstance = WalletInstance,
Config extends Record<string, any> | undefined = undefined,
> = {
export type SelectUIProps<I extends WalletInstance = WalletInstance> = {
/**
* Call this function to "select" your wallet and render the screen for connecting the wallet
* @param selectionData - selectionData to be passed to `connectUI`'s `selectionData` prop
@@ -152,7 +149,7 @@ export type SelectUIProps<
*
* you can use this get metadata of your wallet by doing `walletConfig.meta`
*/
walletConfig: WalletConfig<I, Config>;
walletConfig: WalletConfig<I>;
/**
* List of all supported wallets including your wallet.
@@ -0,0 +1,57 @@
import React, { PropsWithChildren, useEffect, useMemo } from "react";
import { useLogout, useUser } from "../hooks/auth";
import { useWallet } from "../../core/hooks/wallet-hooks";
import { ThirdwebAuthConfig, ThirdwebAuthContext } from "./thirdweb-auth";
export const ThirdwebAuthProvider: React.FC<
PropsWithChildren<{ value?: ThirdwebAuthConfig }>
> = ({ value, children }) => {
// Remove trailing slash from URL if present
const authContext = useMemo(() => {
if (!value) {
return undefined;
}
const context: ThirdwebAuthContext = {
...value,
authUrl: value.authUrl?.replace(/\/$/, ""),
};
return context;
}, [value]);
return (
<ThirdwebAuthContext.Provider value={authContext}>
{children}
<DisconnectOnAccountSwitch />
</ThirdwebAuthContext.Provider>
);
};
function DisconnectOnAccountSwitch() {
const { logout } = useLogout();
const wallet = useWallet();
const { isLoggedIn } = useUser();
useEffect(() => {
const handleChange = (data: { address?: string; chainId?: number }) => {
// if the user changes their account, logout
if (data.address) {
logout();
}
};
const shouldAddListener = wallet && isLoggedIn;
if (shouldAddListener) {
wallet.addListener("change", handleChange);
}
return () => {
if (shouldAddListener) {
wallet.removeListener("change", handleChange);
}
};
}, [wallet, logout, isLoggedIn]);
return null;
}
@@ -1,9 +1,4 @@
import React, {
PropsWithChildren,
createContext,
useContext,
useMemo,
} from "react";
import { createContext, useContext } from "react";
export interface ISecureStorage {
getItem(key: string): Promise<string | null>;
@@ -31,44 +26,21 @@ export interface ThirdwebAuthConfig {
/**
* Secure storage to use for storing the auth token when using JWT tokens.
*
* Do not use a storage option that stores values accessible outside
* your aplication (like localStorage on web environments) since you may
*
* Do not use a storage option that stores values accessible outside
* your aplication (like localStorage on web environments) since you may
* be exposing your auth token to malicious actors.
*
*
* ** By default auth uses cookies so no need to set this unless you want to specifically use JWT tokens **
*/
secureStorage?: ISecureStorage;
}
interface ThirdwebAuthContext extends ThirdwebAuthConfig {}
export interface ThirdwebAuthContext extends ThirdwebAuthConfig {}
const ThirdwebAuthContext = createContext<ThirdwebAuthContext | undefined>(
undefined,
);
export const ThirdwebAuthProvider: React.FC<
PropsWithChildren<{ value?: ThirdwebAuthConfig }>
> = ({ value, children }) => {
// Remove trailing slash from URL if present
const authContext = useMemo(() => {
if (!value) {
return undefined;
}
const context: ThirdwebAuthContext = {
...value,
authUrl: value.authUrl?.replace(/\/$/, ""),
};
return context;
}, [value]);
return (
<ThirdwebAuthContext.Provider value={authContext}>
{children}
</ThirdwebAuthContext.Provider>
);
};
export const ThirdwebAuthContext = createContext<
ThirdwebAuthContext | undefined
>(undefined);
export function useThirdwebAuthContext() {
return useContext(ThirdwebAuthContext);
@@ -0,0 +1,158 @@
import {
RequiredParam,
requiredParamInvariant,
} from "../../../core/query-utils/required-param";
import { useSDKChainId } from "../../providers/thirdweb-sdk-provider";
import { WalletAddress } from "../../types";
import {
cacheKeys,
invalidateContractAndBalances,
} from "../../utils/cache-keys";
import { useQueryWithNetwork } from "../query-utils/useQueryWithNetwork";
import {
useMutation,
useQueryClient,
UseQueryResult,
} from "@tanstack/react-query";
import type {
AccountEvent, SmartContract,
} from "@thirdweb-dev/sdk";
import type { BytesLike } from "ethers";
import invariant from "tiny-invariant";
/** **********************/
/** READ HOOKS **/
/** **********************/
/**
* Get all wallets
*
* @example
* ```javascript
* const { data: smartWallets, isLoading, error } = useSmartWallets(contract);
* ```
*
* @param contract - an instance of a smart wallet factory contract
* @returns a response object that includes an array of all smart wallets with their associated admin
* @twfeature SmartWalletFactory
* @see {@link https://portal.thirdweb.com/react/react.usesmartwallets?utm_source=sdk | Documentation}
* @beta
*/
export function useSmartWallets(
contract: RequiredParam<SmartContract>
): UseQueryResult<AccountEvent[]> {
const contractAddress = contract?.getAddress();
return useQueryWithNetwork(
cacheKeys.contract.smartWalletFactory.getAll(contractAddress),
() => {
requiredParamInvariant(contract, "No Contract instance provided");
invariant(
contract.smartWalletFactory.getAllWallets,
"Contract instance does not support contract.smartWalletFactory.getAllWallets",
);
return contract.smartWalletFactory.getAllWallets();
},
{ enabled: !!contract },
);
}
/**
* Check if a smart wallet has been deployed for the given admin
*
* @example
* ```javascript
* const { data: isSmartWalletDeployed, isLoading, error } = useIsSmartWalletDeployed(contract);
* ```
*
* @param contract - an instance of a smart wallet factory contract
* @returns a boolean indicating if a smart wallet has been deployed for the given admin
* @twfeature SmartWalletFactory
* @see {@link https://portal.thirdweb.com/react/react.useissmartwalletdeployed?utm_source=sdk | Documentation}
* @beta
*/
export function useIsSmartWalletDeployed(
contract: RequiredParam<SmartContract>,
admin: RequiredParam<WalletAddress>,
extraData?: BytesLike,
): UseQueryResult<boolean> {
const contractAddress = contract?.getAddress();
return useQueryWithNetwork(
cacheKeys.contract.smartWalletFactory.getAll(contractAddress),
() => {
requiredParamInvariant(contract, "No Contract instance provided");
invariant(
contract.smartWalletFactory.isWalletDeployed,
"Contract instance does not support contract.smartWalletFactory.getAllWallets",
);
invariant(admin, "No wallet address provided");
return contract.smartWalletFactory.isWalletDeployed(admin, extraData);
},
{ enabled: !!contract },
);
}
/** **********************/
/** WRITE HOOKS **/
/** **********************/
/**
* Create a smart wallet
*
* @example
* ```jsx
* const Component = () => {
* const { contract } = useContract("{{contract_address}}");
* const {
* mutate: createSmartWallet,
* isLoading,
* error,
* } = useCreateSmartWallet(contract);
*
* if (error) {
* console.error("failed to create smart wallet", error);
* }
*
* return (
* <button
* disabled={isLoading}
* onClick={() => createSmartWallet("0x...")}
* >
* Create Smart Wallet
* </button>
* );
* };
* ```
*
* @param contract - an instance of a smart wallet factory contract
* @returns a mutation object that can be used to create a smart wallet
* @twfeature SmartWalletFactory
* @see {@link https://portal.thirdweb.com/react/react.usecreatesmartwallet?utm_source=sdk | Documentation}
* @beta
*/
export function useCreateSmartWallet(
contract: RequiredParam<SmartContract>,
) {
const activeChainId = useSDKChainId();
const contractAddress = contract?.getAddress();
const queryClient = useQueryClient();
return useMutation(
async (admin: string, extraData?: BytesLike) => {
requiredParamInvariant(contract, "contract is undefined");
return contract.smartWalletFactory.createWallet(
admin,
extraData,
);
},
{
onSettled: () =>
invalidateContractAndBalances(
queryClient,
contractAddress,
activeChainId,
),
},
);
}
@@ -27,7 +27,7 @@ export function useLogin() {
const wallet = useWallet();
const login = useMutation({
mutationFn: async (options?: LoginOptions) => {
mutationFn: async () => {
invariant(
authConfig,
"Please specify an authConfig in the ThirdwebProvider",
@@ -38,14 +38,29 @@ export function useLogin() {
"Please specify an authUrl in the authConfig.",
);
// we need to generate this auth payload
const payload = await doLogin(wallet, {
...authConfig,
...(options || {}),
const address = await wallet.getAddress();
let res = await fetch(`${authConfig.authUrl}/payload`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ address }),
});
const res = await fetch(`${authConfig.authUrl}/login`, {
if (!res.ok) {
throw new Error(`Failed to get payload with status code ${res.status}`);
}
let payloadData: LoginPayloadData;
try {
({ payload: payloadData } = await res.json());
} catch {
throw new Error(`Failed to get payload`);
}
const payload = await doLoginWithPayload(wallet, payloadData);
res = await fetch(`${authConfig.authUrl}/login`, {
method: "POST",
headers: {
"Content-Type": "application/json",
@@ -73,11 +88,24 @@ export function useLogin() {
});
return {
login: (options?: LoginOptions) => login.mutateAsync(options),
login: () => login.mutateAsync(),
isLoading: login.isLoading,
};
}
export async function doLoginWithPayload(
wallet: GenericAuthWallet,
payload: LoginPayloadData,
): Promise<LoginPayload> {
const message = generateMessage(payload);
const signature = await wallet.signMessage(message);
return {
payload,
signature,
};
}
export async function doLogin(
wallet: GenericAuthWallet,
options?: LoginOptions,
@@ -109,20 +137,15 @@ export async function doLogin(
nonce: options?.nonce || nonce,
issued_at: new Date().toISOString(),
expiration_time: new Date(
options?.expirationTime || Date.now() + 1000 * 60 * 5,
options?.expirationTime || Date.now() + 1000 * 60 * 10,
).toISOString(),
invalid_before: new Date(
options?.invalidBefore || Date.now(),
options?.invalidBefore || Date.now() - 1000 * 60 * 10,
).toISOString(),
resources: options?.resources,
};
const signature = await wallet.signMessage(generateMessage(payloadData));
return {
payload: payloadData,
signature,
};
return doLoginWithPayload(wallet, payloadData);
}
// generate straight from auth
+9 -4
View File
@@ -47,10 +47,8 @@ export type {
} from "../core/types/wallet";
// auth
export {
ThirdwebAuthProvider,
useThirdwebAuthContext,
} from "./contexts/thirdweb-auth";
export { useThirdwebAuthContext } from "./contexts/thirdweb-auth";
export { ThirdwebAuthProvider } from "./contexts/ThirdwebAuthProvider";
export type {
ThirdwebAuthConfig,
ISecureStorage,
@@ -194,6 +192,13 @@ export {
useBurnToken,
} from "./hooks/async/token";
// smart wallet factory
export {
useIsSmartWalletDeployed,
useSmartWallets,
useCreateSmartWallet,
} from "./hooks/async/smart-wallet-factory";
// thirdweb hooks (work as long as at least `<ThirdwebSdkProvider>` is used)
// auth hooks
@@ -118,6 +118,11 @@ export const cacheKeys = {
overrides,
]),
smartWalletFactory: {
getAll: (contractAddress: RequiredParam<ContractAddress>) =>
createContractCacheKey(contractAddress, ["smartWalletFactory"]),
},
app: {
get: (contractAddress: RequiredParam<ContractAddress>) =>
createContractCacheKey(contractAddress, ["appURI"]),
@@ -37,7 +37,7 @@ export function useLogin() {
const signer = useSDK()?.wallet.getSigner();
const login = useMutation({
mutationFn: async (options?: LoginOptions) => {
mutationFn: async () => {
invariant(
authConfig,
"Please specify an authConfig in the ThirdwebProvider",
@@ -47,9 +47,29 @@ export function useLogin() {
authConfig.authUrl,
"Please specify an authUrl in the authConfig.",
);
const wallet = new SignerWallet(signer);
const address = await wallet.getAddress();
let res = await fetch(`${authConfig.authUrl}/payload`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ address }),
});
const payload = doLogin(new SignerWallet(signer), options);
const res = await fetch(`${authConfig.authUrl}/login`, {
if (!res.ok) {
throw new Error(`Failed to get payload with status code ${res.status}`);
}
let payloadData: LoginPayloadData;
try {
({ payload: payloadData } = await res.json());
} catch {
throw new Error(`Failed to get payload`);
}
const payload = await doLoginWithPayload(wallet, payloadData);
res = await fetch(`${authConfig.authUrl}/login`, {
method: "POST",
headers: {
"Content-Type": "application/json",
@@ -72,7 +92,7 @@ export function useLogin() {
});
return {
login: (options?: LoginOptions) => login.mutateAsync(options),
login: () => login.mutateAsync(),
isLoading: login.isLoading,
};
}
@@ -80,7 +100,20 @@ export function useLogin() {
// login function extracted directly from auth
const isBrowser = () => typeof window !== "undefined";
async function doLogin(
export async function doLoginWithPayload(
wallet: GenericAuthWallet,
payload: LoginPayloadData,
): Promise<LoginPayload> {
const message = generateMessage(payload);
const signature = await wallet.signMessage(message);
return {
payload,
signature,
};
}
export async function doLogin(
wallet: GenericAuthWallet,
options?: LoginOptions,
): Promise<LoginPayload> {
@@ -119,12 +152,7 @@ async function doLogin(
resources: options?.resources,
};
const signature = await wallet.signMessage(generateMessage(payloadData));
return {
payload: payloadData,
signature,
};
return doLoginWithPayload(wallet, payloadData);
}
// generate straight from auth
@@ -1,5 +1,11 @@
# @thirdweb-dev/react-native-compat
## 0.2.18
## 0.2.17
## 0.2.16
## 0.2.15
## 0.2.14
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@thirdweb-dev/react-native-compat",
"description": "Shims for Thirdweb in React Native Projects",
"version": "0.2.15",
"version": "0.2.18",
"author": "thirdweb eng <[email protected]>",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native-compat",
"license": "Apache-2.0",
+100
View File
@@ -1,5 +1,105 @@
# @thirdweb-dev/react-native
## 0.2.18
### Patch Changes
- [#1137](https://github.com/thirdweb-dev/js/pull/1137) [`dec4c4a8`](https://github.com/thirdweb-dev/js/commit/dec4c4a8cfd3f3b257e537fa84ed038e781e6311) Thanks [@iketw](https://github.com/iketw)! - [ReactNative] Export WCV1 and WCV2 abstract classes to facilitate creation of wallet connect based wallets
You can now extend the abstract classes `WalletConnectV1` or `WalletConnectV2` and set your own metadata when implementing a wallet.
Find an example below implementing `MyWallet` that supports the `WalletConnectV2` protocol.
```javascript
import {
WCMeta,
WalletConnectV2,
WalletOptions,
WalletConfig,
} from '@thirdweb-dev/react-native';
export class MyWallet extends WalletConnectV2 {
static id = 'mywallet' as const; // ID needed to identify your wallet in the SDK.
static meta = {
name: 'My Wallet', // Name that will show up in our Connect Modal.
iconURL:
'my-wallet-icon-url-ipfs-or-png', // Icon that will show up in our Connect Modal.
links: { // The WalletConnect mobile links.
native: 'mywallet://',
universal: 'https://mywallet.com',
},
};
getMeta(): WCMeta {
return MyWallet.meta;
}
}
/**
* The WalletConnectV2 projectId.
*
* We provide a default projectId but recommend you get your own
* when launching your app in production.
*/
type MyWalletConfig = { projectId?: string };
export const myWallet = (config?: MyWalletConfig): WalletConfig<WalletConnectV2> => {
return {
id: MyWallet.id,
meta: MyWallet.meta,
create: (options: WalletOptions) =>
new MyWallet({
...options,
projectId: config?.projectId,
walletId: MyWallet.id,
}),
};
};
```
You can then use your new wallet in the `ThirdwebProvider`'s `supportedWallets` prop:
```javascript
import { ThirdwebProvider } from "@thirdweb-dev/react-native";
<ThirdwebProvider supportedWallets={[myWallet()]}>
<App />
</ThirdwebProvider>;
```
- [#1151](https://github.com/thirdweb-dev/js/pull/1151) [`2a0294d8`](https://github.com/thirdweb-dev/js/commit/2a0294d8e67bbc08dcf59c79174a7626deb0e90a) Thanks [@MananTank](https://github.com/MananTank)! - Fix wrong balance in ConnectWallet
- [#1135](https://github.com/thirdweb-dev/js/pull/1135) [`15ef4779`](https://github.com/thirdweb-dev/js/commit/15ef4779e0a95cbae3053bdecfd4d54e4c30b07b) Thanks [@iketw](https://github.com/iketw)! - [ReactNative] Exports base UI components (react-native/components/base). They can now be used in your application.
- [#1144](https://github.com/thirdweb-dev/js/pull/1144) [`9ce3eb6a`](https://github.com/thirdweb-dev/js/commit/9ce3eb6aad957aff38fb4a25383ed17ff58e988f) Thanks [@MananTank](https://github.com/MananTank)! - Remove WalletConfig.config object from wallets
- Updated dependencies [[`2a443365`](https://github.com/thirdweb-dev/js/commit/2a443365bdc3d47d0f41fc895f70256dcde423f5), [`3bf7f375`](https://github.com/thirdweb-dev/js/commit/3bf7f375933cbd7dd8c682a66e8c67bbcb268bf7), [`6a194262`](https://github.com/thirdweb-dev/js/commit/6a19426200297b8da158c7d860d31efcc8c15822), [`16232de9`](https://github.com/thirdweb-dev/js/commit/16232de9eab9966e24e335929b2a3919346af265), [`54cfd6d8`](https://github.com/thirdweb-dev/js/commit/54cfd6d8916c42d87b6aa438e607ce525766b686), [`8687d6ac`](https://github.com/thirdweb-dev/js/commit/8687d6ac3a363eae63eeb1959a953cbcd282d353), [`645b0303`](https://github.com/thirdweb-dev/js/commit/645b0303cc1a9cbb0a0e9cbd67d11c3b865e4584), [`522453fd`](https://github.com/thirdweb-dev/js/commit/522453fd568b8c350141a96f9f1c6d5a3ef74493), [`9a015a23`](https://github.com/thirdweb-dev/js/commit/9a015a23cde09c8ba6c36593a84303ffe409a79a), [`6803c3e9`](https://github.com/thirdweb-dev/js/commit/6803c3e97ca74eed19cd90095afde25b02150d51), [`0cba69ca`](https://github.com/thirdweb-dev/js/commit/0cba69ca40a8cf6f106344247d0082212cd169da), [`56f85e57`](https://github.com/thirdweb-dev/js/commit/56f85e57df84bfa93e3230639c95d12466f8aec7), [`197a6838`](https://github.com/thirdweb-dev/js/commit/197a6838f69ae8b9ad46524e7c469fc757d0a2cb), [`6a91b6a0`](https://github.com/thirdweb-dev/js/commit/6a91b6a0253bab5914d4ebdad951dd1c5d141fbc), [`e32faeb5`](https://github.com/thirdweb-dev/js/commit/e32faeb57a5c2193c40cb6129fab92b84069b12d), [`a5f16b6d`](https://github.com/thirdweb-dev/js/commit/a5f16b6dc50b37920a6e5210b60aa6a1682ceb63), [`b6728603`](https://github.com/thirdweb-dev/js/commit/b6728603972ccd6c95108b25e8562807f0f95e19), [`ed47fd53`](https://github.com/thirdweb-dev/js/commit/ed47fd5310d11323080d984bca18a96fdef3a977), [`9ce3eb6a`](https://github.com/thirdweb-dev/js/commit/9ce3eb6aad957aff38fb4a25383ed17ff58e988f)]:
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
## 0.2.17
### Patch Changes
- Updated dependencies [[`ce36322b`](https://github.com/thirdweb-dev/js/commit/ce36322b383af73905894b73f9409a146359ffb0), [`c60658ed`](https://github.com/thirdweb-dev/js/commit/c60658ed8c94867cca831b0d5535006da5b40aa6), [`aa9e952c`](https://github.com/thirdweb-dev/js/commit/aa9e952cb519a47ed112d2905b1f3787863035b6), [`564eaccf`](https://github.com/thirdweb-dev/js/commit/564eaccf480a81f36db43c782392595a5021e5ac), [`6aee0413`](https://github.com/thirdweb-dev/js/commit/6aee0413439b9ca408879bbb3c38c538c89d01af), [`21627c03`](https://github.com/thirdweb-dev/js/commit/21627c03d1bb1658fee19b12d580faa6c7f048d9), [`2283e71a`](https://github.com/thirdweb-dev/js/commit/2283e71acaaf3d15eb2d6121682f1d2a81eec4f3), [`e93aa70e`](https://github.com/thirdweb-dev/js/commit/e93aa70ef0093a2526404e11b7ddae8fb98c213b), [`51bbd3d1`](https://github.com/thirdweb-dev/js/commit/51bbd3d1bccbb92a1405ea50f6c178c091a90f20), [`9b20fc9a`](https://github.com/thirdweb-dev/js/commit/9b20fc9ad2d303edc31f44fbd2ea3b4dcf35d11e)]:
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
## 0.2.16
### Patch Changes
- [#1103](https://github.com/thirdweb-dev/js/pull/1103) [`89102b0c`](https://github.com/thirdweb-dev/js/commit/89102b0c895011bb6528d2b9bc4289173b351c8d) Thanks [@iketw](https://github.com/iketw)! - [ReactNative] Fix bug where the wc uri is not being copied in the textinput after scanning it
- Updated dependencies [[`23d90b3e`](https://github.com/thirdweb-dev/js/commit/23d90b3e779a5bfdb7058b8c51349d9c278fcbce), [`cc56037e`](https://github.com/thirdweb-dev/js/commit/cc56037e64560b9e0fc16eb0ac7cc2e47e2c9fdf), [`67450789`](https://github.com/thirdweb-dev/js/commit/67450789473b6008b86453ee4f4c7b99461223a6)]:
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
## 0.2.15
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/react-native",
"version": "0.2.15",
"version": "0.2.18",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
@@ -1,68 +1,26 @@
import { ThemeProvider, ThemeProviderProps } from "../styles/ThemeProvider";
import { ConnectWalletDetails } from "./ConnectWalletDetails/ConnectWalletDetails";
import {
useAddress,
useConnectionStatus,
useWallets,
} from "@thirdweb-dev/react-core";
import React, { useEffect, useRef, useState } from "react";
import { ActivityIndicator, Animated, StyleSheet } from "react-native";
import BaseButton from "./base/BaseButton";
import Text from "./base/Text";
import { useModalState } from "../providers/ui-context-provider";
import { ThemeProvider } from "../styles/ThemeProvider";
import { WalletDetailsButton } from "./ConnectWalletDetails/WalletDetailsButton";
import { useAddress } from "@thirdweb-dev/react-core";
import React, { useEffect, useRef } from "react";
import { Animated } from "react-native";
import { ConnectWalletButton } from "./ConnectWalletFlow/ConnectWalletButton";
import { ConnectWalletButtonProps } from "./ConnectWalletFlow/ConnectWalletButton";
export type ConnectWalletProps = {
theme?: ThemeProviderProps["theme"];
/**
* Set a custom title for the button
* @default "Connect Wallet"
*/
buttonTitle?: string;
/**
* Set a custom title for the Connect Wallet modal
* @default "Choose your wallet"
*/
modalTitle?: string;
/**
* render a custom button to display the connected wallet details instead of the default button
*/
detailsButton?: React.ReactElement;
};
} & ConnectWalletButtonProps;
export const ConnectWallet = ({
buttonTitle,
detailsButton,
modalTitle,
theme,
buttonTitle,
modalTitle,
}: ConnectWalletProps) => {
const fadeAnim = useRef(new Animated.Value(0)).current;
const address = useAddress();
const connectionStatus = useConnectionStatus();
const supportedWallets = useWallets();
const isWalletConnecting = connectionStatus === "connecting";
const [showButtonSpinner, setShowButtonSpinner] = useState(false);
const { setModalState } = useModalState();
useEffect(() => {
setShowButtonSpinner(isWalletConnecting);
if (!isWalletConnecting) {
setShowButtonSpinner(false);
return;
}
const timeout = setTimeout(() => {
if (isWalletConnecting) {
setShowButtonSpinner(false);
}
}, 5000);
return () => {
if (timeout) {
clearTimeout(timeout);
}
};
}, [isWalletConnecting]);
useEffect(() => {
Animated.timing(fadeAnim, {
@@ -72,60 +30,22 @@ export const ConnectWallet = ({
}).start();
}, [fadeAnim]);
const onConnectWalletPress = () => {
setModalState({
isOpen: true,
isSheet: true,
view: "ConnectWalletFlow",
data: {
modalTitle,
walletConfig:
supportedWallets.length === 1 ? supportedWallets[0] : undefined,
},
caller: "ConnectWallet",
});
};
return (
<ThemeProvider theme={theme}>
<Animated.View style={{ opacity: fadeAnim }}>
{address ? (
<ConnectWalletDetails
<WalletDetailsButton
address={address}
detailsButton={detailsButton}
/>
) : (
<BaseButton
backgroundColor="buttonBackgroundColor"
onPress={onConnectWalletPress}
style={styles.connectWalletButton}
>
<Text variant="bodyLarge" color="buttonTextColor">
{showButtonSpinner ? (
<ActivityIndicator size="small" color="buttonTextColor" />
) : buttonTitle ? (
buttonTitle
) : (
"Connect Wallet"
)}
</Text>
</BaseButton>
<ConnectWalletButton
modalTitle={modalTitle}
buttonTitle={buttonTitle}
theme={theme}
/>
)}
</Animated.View>
</ThemeProvider>
);
};
const styles = StyleSheet.create({
connectWalletButton: {
display: "flex",
flexDirection: "row",
alignContent: "center",
alignItems: "center",
justifyContent: "center",
borderRadius: 8,
paddingHorizontal: 10,
paddingVertical: 10,
minWidth: 150,
},
});
@@ -80,11 +80,11 @@ const ConnectAppField = () => {
};
const onQRCodeScan = (data: string) => {
if (wcUri !== data) {
if (wcUri !== data && data.startsWith("wc:")) {
setWCUri(data);
setShowQRCodeScan(false);
onWCPress();
onWCPress(data);
}
};
@@ -92,13 +92,15 @@ const ConnectAppField = () => {
setShowQRCodeScan(false);
};
const onWCPress = () => {
if (!wcUri || !wallet) {
const onWCPress = (uri?: string) => {
if (!(wcUri || uri) || !wallet) {
return;
}
if (wcUri.startsWith("wc:")) {
(wallet as unknown as IWalletConnectReceiver).connectApp(wcUri);
const uriToUse = uri || wcUri;
if (uriToUse?.startsWith("wc:")) {
(wallet as unknown as IWalletConnectReceiver).connectApp(uriToUse);
}
};
@@ -119,11 +121,12 @@ const ConnectAppField = () => {
<TextInput
onChangeText={onAddressChangeText}
flex={1}
value={wcUri}
placeholder={"wc://..."}
placeholderTextColor={theme.colors.textSecondary}
/>
<BaseButton
onPress={onWCPress}
onPress={() => onWCPress()}
justifyContent="center"
alignItems="center"
>
@@ -12,7 +12,7 @@ export const QRCodeScan = ({
onClose: () => void;
}) => {
return (
<TWModal isVisible={isVisible} backdropOpacity={0.7}>
<TWModal isVisible={isVisible} backdropOpacity={1}>
<ModalHeaderTextClose headerText={"Scan to Connect"} onClose={onClose} />
<RNCamera
style={{ flex: 1 }}
@@ -95,7 +95,7 @@ export const SessionRequestModal = () => {
default:
throw new Error(`Method not implemented: ${requestData.method}`);
}
}, [requestData]);
}, [chain?.chainId, chain?.slug, requestData]);
return (
<Box
@@ -7,7 +7,7 @@ import {
SmartWallet,
walletIds,
} from "@thirdweb-dev/wallets";
import { Address } from "../base/Address";
import { AddressDisplay } from "../base/AddressDisplay";
import Text from "../base/Text";
import { usePersonalWalletAddress } from "../../wallets/hooks/usePersonalWalletAddress";
import { useWalletContext, useWallet } from "@thirdweb-dev/react-core";
@@ -80,7 +80,7 @@ export const SmartWalletAdditionalActions = ({
<WalletIcon size={32} iconUri={wallet?.getMeta().iconURL || ""} />
) : null}
<View style={styles.walletInfo}>
<Address
<AddressDisplay
variant="bodyLarge"
address={
showSmartWallet ? smartWalletAddress : personalWalletAddress
@@ -1,4 +1,4 @@
import { Address } from "../base/Address";
import { AddressDisplay } from "../base/AddressDisplay";
import BaseButton from "../base/BaseButton";
import { ChainIcon } from "../base/ChainIcon";
import Text from "../base/Text";
@@ -15,7 +15,7 @@ export type ConnectWalletDetailsProps = {
detailsButton?: React.ReactElement;
};
export const ConnectWalletDetails = ({
export const WalletDetailsButton = ({
address,
detailsButton,
}: ConnectWalletDetailsProps) => {
@@ -51,13 +51,18 @@ export const ConnectWalletDetails = ({
<ChainIcon size={32} chainIconUrl={chain?.icon?.url} />
<Box justifyContent="center" alignItems="flex-start">
<Text variant="bodySmall">
{balanceQuery.data?.displayValue.slice(0, 5)}{" "}
{balanceQuery.data
? Number(balanceQuery.data.displayValue).toFixed(3)
: ""}{" "}
{balanceQuery.data?.symbol}
</Text>
{activeWallet?.walletId === LocalWallet.id ? (
<Text variant="error">Guest</Text>
) : (
<Address variant="bodySmallSecondary" address={address} />
<AddressDisplay
variant="bodySmallSecondary"
address={address}
/>
)}
</Box>
<WalletIcon
@@ -1,6 +1,6 @@
import { Icon } from "../../assets/icon";
import { useAppTheme } from "../../styles/hooks";
import { Address } from "../base/Address";
import { AddressDisplay } from "../base/AddressDisplay";
import BaseButton from "../base/BaseButton";
import Text from "../base/Text";
import { WalletIcon } from "../base/WalletIcon";
@@ -55,7 +55,7 @@ export const WalletDetailsModalHeader = ({
justifyContent="center"
alignItems="center"
>
<Address mr="xs" address={address} />
<AddressDisplay mr="xs" address={address} />
<CopyIcon
width={14}
height={14}
@@ -63,7 +63,9 @@ export const WalletDetailsModalHeader = ({
/>
</Box>
<Text variant="bodySmallSecondary">
{balanceQuery.data?.displayValue.slice(0, 5)}{" "}
{balanceQuery.data
? Number(balanceQuery.data.displayValue).toFixed(3)
: ""}{" "}
{balanceQuery.data?.symbol}
</Text>
</BaseButton>
@@ -10,9 +10,9 @@ import { View } from "react-native";
export type ChooseWalletProps = {
headerText?: ReactNode | string;
subHeaderText?: ReactNode | string;
onChooseWallet: (wallet: WalletConfig<any, any>, data?: any) => void;
onChooseWallet: (wallet: WalletConfig<any>, data?: any) => void;
onClose: () => void;
wallets: WalletConfig<any, any>[];
wallets: WalletConfig<any>[];
excludeWalletIds?: string[];
showGuestWalletAsButton?: boolean;
};
@@ -0,0 +1,102 @@
import { ActivityIndicator, StyleSheet } from "react-native";
import { BaseButton, Text } from "../base";
import { useConnectionStatus, useWallets } from "@thirdweb-dev/react-core";
import { useState, useEffect } from "react";
import { useModalState } from "../../providers/ui-context-provider";
import { ThemeProvider, ThemeProviderProps } from "../../styles/ThemeProvider";
export type ConnectWalletButtonProps = {
theme?: ThemeProviderProps["theme"];
/**
* Set a custom title for the button
* @default "Connect Wallet"
*/
buttonTitle?: string;
/**
* Set a custom title for the Connect Wallet modal
* @default "Choose your wallet"
*/
modalTitle?: string;
};
export const ConnectWalletButton = ({
modalTitle,
buttonTitle,
theme,
}: ConnectWalletButtonProps) => {
const connectionStatus = useConnectionStatus();
const isWalletConnecting = connectionStatus === "connecting";
const supportedWallets = useWallets();
const [showButtonSpinner, setShowButtonSpinner] = useState(false);
const { setModalState } = useModalState();
useEffect(() => {
setShowButtonSpinner(isWalletConnecting);
if (!isWalletConnecting) {
setShowButtonSpinner(false);
return;
}
const timeout = setTimeout(() => {
if (isWalletConnecting) {
setShowButtonSpinner(false);
}
}, 5000);
return () => {
if (timeout) {
clearTimeout(timeout);
}
};
}, [isWalletConnecting]);
const onConnectWalletPress = () => {
setModalState({
isOpen: true,
isSheet: true,
view: "ConnectWalletFlow",
data: {
modalTitle,
walletConfig:
supportedWallets.length === 1 ? supportedWallets[0] : undefined,
},
caller: "ConnectWallet",
});
};
return (
<ThemeProvider theme={theme}>
<BaseButton
backgroundColor="buttonBackgroundColor"
onPress={onConnectWalletPress}
style={styles.connectWalletButton}
>
<Text variant="bodyLarge" color="buttonTextColor">
{showButtonSpinner ? (
<ActivityIndicator size="small" color="buttonTextColor" />
) : buttonTitle ? (
buttonTitle
) : (
"Connect Wallet"
)}
</Text>
</BaseButton>
</ThemeProvider>
);
};
const styles = StyleSheet.create({
connectWalletButton: {
display: "flex",
flexDirection: "row",
alignContent: "center",
alignItems: "center",
justifyContent: "center",
borderRadius: 8,
paddingHorizontal: 10,
paddingVertical: 10,
minWidth: 150,
},
});
@@ -69,10 +69,10 @@ export const SmartWalletFlow = ({
);
useEffect(() => {
if (walletObj.config.personalWallets?.length === 1) {
onChoosePersonalWallet(walletObj.config.personalWallets[0]);
if (walletObj.personalWallets?.length === 1) {
onChoosePersonalWallet(walletObj.personalWallets[0]);
}
}, [onChoosePersonalWallet, walletObj.config.personalWallets]);
}, [onChoosePersonalWallet, walletObj.personalWallets]);
useEffect(() => {
(async () => {
@@ -203,7 +203,7 @@ export const SmartWalletFlow = ({
</Text>
</Text>
}
wallets={walletObj.config.personalWallets || DEFAULT_WALLETS}
wallets={walletObj.personalWallets || DEFAULT_WALLETS}
onChooseWallet={onChoosePersonalWallet}
onClose={onClose}
/>
@@ -7,7 +7,7 @@ type AddressProps = {
variant?: keyof Theme["textVariants"];
} & (typeof Text)["arguments"];
export const Address = ({
export const AddressDisplay = ({
address,
variant = "bodyLarge",
...props
@@ -0,0 +1,13 @@
export { ActiveDot } from "./ActiveDot";
export { AddressDisplay } from "./AddressDisplay";
export { default as BaseButton } from "./BaseButton";
export { default as Box } from "./Box";
export { ChainIcon } from "./ChainIcon";
export { default as ImageSvgUri } from "./ImageSvgUri";
export { Label } from "./Label";
export { Link } from "./Link";
export { default as Text } from "./Text";
export { TextInput } from "./TextInput";
export { Toast } from "./Toast";
export { WalletButton } from "./WalletButton";
export { WalletIcon } from "./WalletIcon";
@@ -3,7 +3,7 @@ import { metamaskWallet } from "../wallets/wallets/metamask-wallet";
import { rainbowWallet } from "../wallets/wallets/rainbow-wallet";
import { trustWallet } from "../wallets/wallets/trust-wallet";
export const DEFAULT_WALLETS: WalletConfig<any, any>[] = [
export const DEFAULT_WALLETS: WalletConfig<any>[] = [
metamaskWallet(),
rainbowWallet(),
trustWallet(),
+6
View File
@@ -17,6 +17,9 @@ export { localWallet } from "./wallets/wallets/local-wallet";
export { LocalWallet } from "./wallets/wallets/LocalWallet";
export { magicWallet } from "./wallets/wallets/magic-wallet";
export { MagicWallet } from "./wallets/wallets/MagicWallet";
export * from "./wallets/wallets/WalletConnectV1";
export * from "./wallets/wallets/WalletConnectV2";
export type { WCMeta } from "./wallets/types/wc";
export { useCoinbaseWallet } from "./wallets/hooks/useCoinbaseWallet";
export { useMetaMaskWallet } from "./wallets/hooks/useMetaMaskWallet";
@@ -33,6 +36,9 @@ export { createSyncStorage as createLocalStorage } from "../core/AsyncStorage";
export { createAsyncLocalStorage } from "../core/AsyncStorage";
export { createSecureStorage } from "../core/SecureStorage";
// ui components
export * from "./components/base";
// providers
// export * from "./providers/full";
export * from "./providers/thirdweb-provider";
@@ -32,7 +32,7 @@ interface ThirdwebProviderProps<TChains extends Chain[]>
* />
* ```
*/
supportedWallets?: WalletConfig<any, any>[];
supportedWallets?: WalletConfig<any>[];
}
/**
+3 -1
View File
@@ -1,3 +1,5 @@
import { WCMeta } from "../wallets/types/wc";
/**
* Build a WalletConnect display URI from a wc:// uri + a wallet specific link
*
@@ -7,7 +9,7 @@
*/
export function formatWalletConnectDisplayUri(
uri: string,
links: { universal: string; native: string },
links: WCMeta["links"],
) {
const encodedUri: string = encodeURIComponent(uri);
return links.universal
@@ -0,0 +1,8 @@
export type WCMeta = {
name: string;
iconURL: string;
links: {
native?: string;
universal?: string;
};
};
@@ -1,13 +1,11 @@
import {
LocalWallet as LocalWalletCore,
Connector,
walletIds,
} from "@thirdweb-dev/wallets";
import { ethers, utils } from "ethers";
export class LocalWallet extends LocalWalletCore {
static meta = {
id: walletIds.localWallet,
name: "Guest Wallet",
iconURL:
"ipfs://QmQAyJG3y2wZf9u6JXxn8U9Kd1ZVfjtQkf5aua8FcWr8Gm/local-wallet-mobile.svg",
@@ -0,0 +1,52 @@
import {
WalletOptions,
WalletConnectV1Options,
WalletConnectV1 as WalletConnectV1Wallets,
} from "@thirdweb-dev/wallets";
import { formatWalletConnectDisplayUri } from "../../utils/uri";
import { Linking } from "react-native";
import { ExtraCoreWalletOptions } from "@thirdweb-dev/react-core";
import { WCMeta } from "../types/wc";
import { createAsyncLocalStorage } from "../../../core/AsyncStorage";
export type WC1Options = Omit<
WalletOptions<WalletConnectV1Options>,
"qrcode" | "walletId"
> &
ExtraCoreWalletOptions & {
walletId: NonNullable<WalletOptions["walletId"]>;
};
export abstract class WalletConnectV1 extends WalletConnectV1Wallets {
constructor(options: WC1Options) {
super({
...options,
walletId: options.walletId,
walletStorage:
options.walletStorage || createAsyncLocalStorage(options.walletId),
qrcode: false,
});
this.on("open_wallet", this._onWCOpenWallet);
this.on("disconnect", () => {
this.removeListener("open_wallet", this._onWCOpenWallet);
});
}
abstract getMeta(): WCMeta;
_onWCOpenWallet(uri?: string) {
const links = this.getMeta().links;
if (uri) {
const fullUrl = formatWalletConnectDisplayUri(uri, links);
Linking.openURL(fullUrl);
} else {
const fullUrl = formatWalletConnectDisplayUri("", links);
Linking.openURL(fullUrl);
}
}
}
@@ -0,0 +1,60 @@
import { TW_WC_PROJECT_ID } from "../../constants/walletConnect";
import { formatWalletConnectDisplayUri } from "../../utils/uri";
import type {
WalletConnectOptions,
WalletOptions,
} from "@thirdweb-dev/wallets";
import { WalletConnect as WalletConnectV2Wallets } from "@thirdweb-dev/wallets";
import { Linking } from "react-native";
import { WCMeta } from "../types/wc";
import { createAsyncLocalStorage } from "../../../core/AsyncStorage";
export type WC2Options = {
/**
* The WalletConnectV2 projectId.
*
* We provide a default projectId but recommend you get your own
* when launching your app in production.
*/
projectId?: string;
} & Omit<
WalletOptions<WalletConnectOptions>,
"projectId" | "qrcode" | "qrModalOptions"
> & {
walletId: NonNullable<WalletOptions["walletId"]>;
};
export abstract class WalletConnectV2 extends WalletConnectV2Wallets {
constructor(options: WC2Options) {
super({
...options,
walletId: options.walletId,
qrcode: false,
projectId: options.projectId ? options.projectId : TW_WC_PROJECT_ID,
walletStorage:
options.walletStorage || createAsyncLocalStorage(options.walletId),
});
this.on("open_wallet", this._onWCOpenWallet);
this.on("disconnect", () => {
this.removeListener("open_wallet", this._onWCOpenWallet);
});
}
abstract getMeta(): WCMeta;
_onWCOpenWallet(uri?: string) {
const links = this.getMeta().links;
if (uri) {
const fullUrl = formatWalletConnectDisplayUri(uri, links);
Linking.openURL(fullUrl);
} else {
const fullUrl = formatWalletConnectDisplayUri("", links);
Linking.openURL(fullUrl);
}
}
}
@@ -22,7 +22,6 @@ type CoinbaseWalletOptions = Omit<
export class CoinbaseWallet extends AbstractClientWallet<CoinbaseWalletConnectorOptions> {
static meta = {
id: "coinbase",
name: "Coinbase Wallet",
iconURL:
"ipfs://QmcJBHopbwfJcLqJpX2xEufSS84aLbF7bHavYhaXUcrLaH/coinbase.svg",
@@ -82,6 +81,5 @@ export const coinbaseWallet = (config?: { callbackURL?: URL }) => {
meta: CoinbaseWallet.meta,
create: (options: WalletOptionsRC) =>
new CoinbaseWallet({ ...options, callbackURL: callbackURLNonNull }),
config: config || {},
} satisfies WalletConfig<CoinbaseWallet, { callbackURL?: URL }>;
} satisfies WalletConfig<CoinbaseWallet>;
};
@@ -19,26 +19,30 @@ import { ActivityIndicator } from "react-native";
import { useMagicWallet } from "../../providers/context-provider";
export const magicWallet = (
config: MagicLinkOptions,
): WalletConfig<MagicWallet, MagicLinkOptions> => {
magicLinkOptions: MagicLinkOptions,
): WalletConfig<MagicWallet> => {
return {
id: walletIds.magicLink,
meta: MagicWallet.meta,
create: (options: WalletOptions) => {
return new MagicWallet({
...options,
...config,
...magicLinkOptions,
chainId: options.chain.chainId,
});
},
/**
* UI for connecting wallet
*/
connectUI: MagicConnectionUI,
connectUI(props) {
return (
<MagicConnectionUI {...props} magicLinkOptions={magicLinkOptions} />
);
},
/**
* UI for selecting wallet - this UI is rendered in the wallet selection screen
*/
selectUI: (props: SelectUIProps<MagicWallet, MagicLinkOptions>) => {
selectUI: (props: SelectUIProps<MagicWallet>) => {
return (
<Box flex={1}>
<TextInput
@@ -63,15 +67,12 @@ export const magicWallet = (
isInstalled: () => {
return true;
},
config: {
...config,
},
};
};
const MagicConnectionUI: React.FC<
ConnectUIProps<MagicWallet, MagicLinkOptions>
> = ({ selectionData, walletConfig, close }) => {
ConnectUIProps<MagicWallet> & { magicLinkOptions: MagicLinkOptions }
> = ({ selectionData, walletConfig, close, magicLinkOptions }) => {
const createWalletInstance = useCreateWalletInstance();
const setConnectedWallet = useSetConnectedWallet();
const chainToConnect = useWalletContext().chainToConnect;
@@ -98,7 +99,7 @@ const MagicConnectionUI: React.FC<
setConnectionStatus("connecting");
const connectParams = {
chainId: chainToConnect?.chainId,
...walletConfig.config,
...magicLinkOptions,
...(isEmail
? { email: selectionData }
: { phoneNumber: selectionData }),
@@ -122,6 +123,7 @@ const MagicConnectionUI: React.FC<
setConnectedWallet,
setConnectionStatus,
chainToConnect?.chainId,
magicLinkOptions,
]);
return (
@@ -1,28 +1,11 @@
import {
WalletOptions,
WalletConnectV1Options,
WalletConnectV1,
walletIds,
} from "@thirdweb-dev/wallets";
import { formatWalletConnectDisplayUri } from "../../utils/uri";
import { Linking } from "react-native";
import {
WalletOptions as WalletOptionsRC,
WalletConfig,
ExtraCoreWalletOptions,
} from "@thirdweb-dev/react-core";
import { createAsyncLocalStorage } from "../../../core/AsyncStorage";
type WC1Options = Omit<
WalletOptions<WalletConnectV1Options>,
"qrcode" | "walletStorage"
> &
ExtraCoreWalletOptions;
import { walletIds } from "@thirdweb-dev/wallets";
import { WalletOptions, WalletConfig } from "@thirdweb-dev/react-core";
import { WalletConnectV1 } from "./WalletConnectV1";
import { WCMeta } from "../types/wc";
export class MetaMaskWallet extends WalletConnectV1 {
static id = walletIds.metamask;
static meta = {
id: walletIds.metamask,
name: "MetaMask",
iconURL:
"ipfs://QmZZHcw7zcXursywnLDAyY6Hfxzqop5GKgwoq8NB9jjrkN/metamask.svg",
@@ -32,34 +15,8 @@ export class MetaMaskWallet extends WalletConnectV1 {
},
};
constructor(options: WC1Options) {
const storage = createAsyncLocalStorage(walletIds.metamask);
super({
...options,
walletId: walletIds.metamask,
walletStorage: storage,
qrcode: false,
});
this.on("open_wallet", this._onWCOpenWallet);
this.on("disconnect", () => {
this.removeListener("open_wallet", this._onWCOpenWallet);
});
}
_onWCOpenWallet(uri?: string) {
const links = MetaMaskWallet.meta.links;
if (uri) {
const fullUrl = formatWalletConnectDisplayUri(uri, links);
Linking.openURL(fullUrl);
} else {
const fullUrl = formatWalletConnectDisplayUri("", links);
Linking.openURL(fullUrl);
}
getMeta(): WCMeta {
return MetaMaskWallet.meta;
}
}
@@ -67,6 +24,7 @@ export const metamaskWallet = () => {
return {
id: MetaMaskWallet.id,
meta: MetaMaskWallet.meta,
create: (options: WalletOptionsRC) => new MetaMaskWallet(options),
create: (options: WalletOptions) =>
new MetaMaskWallet({ ...options, walletId: walletIds.metamask }),
} satisfies WalletConfig;
};
@@ -1,27 +1,12 @@
import {
WalletOptions,
WalletConnectV1Options,
WalletConnectV1,
} from "@thirdweb-dev/wallets";
import { formatWalletConnectDisplayUri } from "../../utils/uri";
import { Linking } from "react-native";
import {
WalletOptions as WalletOptionsRC,
WalletConfig,
ExtraCoreWalletOptions,
} from "@thirdweb-dev/react-core";
import { createAsyncLocalStorage } from "../../../core/AsyncStorage";
type WC1Options = Omit<
WalletOptions<WalletConnectV1Options>,
"qrcode" | "walletStorage"
> &
ExtraCoreWalletOptions;
import { WalletConnectV1 } from "./WalletConnectV1";
export class RainbowWallet extends WalletConnectV1 {
static id = "rainbow" as const;
static meta = {
id: "rainbow",
name: "Rainbow",
iconURL:
"https://registry.walletconnect.org/v2/logo/md/7a33d7f1-3d12-4b5c-f3ee-5cd83cb1b500",
@@ -31,33 +16,8 @@ export class RainbowWallet extends WalletConnectV1 {
},
};
constructor(options: WC1Options) {
const storage = createAsyncLocalStorage("rainbow");
super({
...options,
walletId: "rainbow",
walletStorage: storage,
qrcode: false,
});
this.on("open_wallet", this._onWCOpenWallet);
this.on("disconnect", () => {
this.removeListener("open_wallet", this._onWCOpenWallet);
});
}
_onWCOpenWallet(uri?: string) {
const links = RainbowWallet.meta.links;
if (uri) {
const fullUrl = formatWalletConnectDisplayUri(uri, links);
Linking.openURL(fullUrl);
} else {
const fullUrl = formatWalletConnectDisplayUri("", links);
Linking.openURL(fullUrl);
}
getMeta() {
return RainbowWallet.meta;
}
}
@@ -65,6 +25,7 @@ export const rainbowWallet = () => {
return {
id: RainbowWallet.id,
meta: RainbowWallet.meta,
create: (options: WalletOptionsRC) => new RainbowWallet(options),
create: (options: WalletOptionsRC) =>
new RainbowWallet({ ...options, walletId: RainbowWallet.id }),
} satisfies WalletConfig;
};
@@ -8,14 +8,14 @@ import { DEFAULT_WALLETS } from "../../constants/wallets";
import { createSyncStorage } from "../../../core/AsyncStorage";
type SmartWalletConfig = {
personalWallets?: WalletConfig<any, any>[];
personalWallets?: WalletConfig<any>[];
} & Omit<SmartWalletConfigWallets, "chain">;
export type SmartWalletObj = WalletConfig<SmartWallet, SmartWalletConfig>;
export type SmartWalletObj = WalletConfig<SmartWallet>;
export const smartWallet = (
config: SmartWalletConfig,
): WalletConfig<SmartWallet, SmartWalletConfig> => {
): WalletConfig<SmartWallet> => {
return {
id: SmartWallet.id,
meta: SmartWallet.meta,
@@ -26,9 +26,6 @@ export const smartWallet = (
walletStorage: createAsyncLocalStorage("smart-wallet"),
wcStorage: createSyncStorage("smart-wallet"),
}),
config: {
...config,
personalWallets: config.personalWallets || DEFAULT_WALLETS,
},
personalWallets: config.personalWallets || DEFAULT_WALLETS,
};
};
@@ -1,26 +1,10 @@
import { createAsyncLocalStorage } from "../../../core/AsyncStorage";
import { TW_WC_PROJECT_ID } from "../../constants/walletConnect";
import { formatWalletConnectDisplayUri } from "../../utils/uri";
import type {
WalletConnectOptions,
WalletOptions,
} from "@thirdweb-dev/wallets";
import {
WalletOptions as WalletOptionsRC,
WalletConfig,
} from "@thirdweb-dev/react-core";
import { WalletConnect } from "@thirdweb-dev/wallets";
import { Linking } from "react-native";
import { WalletOptions, WalletConfig } from "@thirdweb-dev/react-core";
import { WC2Options, WalletConnectV2 } from "./WalletConnectV2";
import { WCMeta } from "../types/wc";
type WC2Options = { projectId?: string } & Omit<
WalletOptions<WalletConnectOptions>,
"projectId" | "qrcode" | "walletStorage" | "qrModalOptions"
>;
export class TrustWallet extends WalletConnect {
export class TrustWallet extends WalletConnectV2 {
static id = "trust" as const;
static meta = {
id: "trust",
name: "Trust Wallet",
iconURL:
"https://registry.walletconnect.org/v2/logo/md/0528ee7e-16d1-4089-21e3-bbfb41933100",
@@ -31,48 +15,25 @@ export class TrustWallet extends WalletConnect {
};
constructor(options: WC2Options) {
const storage = createAsyncLocalStorage("trustwallet");
super({
...options,
walletId: "trust",
qrcode: false,
projectId: options.projectId ? options.projectId : TW_WC_PROJECT_ID,
walletStorage: storage,
});
this.on("open_wallet", this._onWCOpenWallet);
this.on("disconnect", () => {
this.removeListener("open_wallet", this._onWCOpenWallet);
});
super(options);
}
_onWCOpenWallet(uri?: string) {
const links = TrustWallet.meta.links;
if (uri) {
const fullUrl = formatWalletConnectDisplayUri(uri, links);
Linking.openURL(fullUrl);
} else {
const fullUrl = formatWalletConnectDisplayUri("", links);
Linking.openURL(fullUrl);
}
getMeta(): WCMeta {
return TrustWallet.meta;
}
}
type TrustWalletConfig = { projectId?: string };
export const trustWallet = (config?: TrustWalletConfig) => {
const projectId = config?.projectId ? config.projectId : TW_WC_PROJECT_ID;
return {
id: TrustWallet.id,
meta: TrustWallet.meta,
create: (options: WalletOptionsRC) =>
new TrustWallet({ ...options, projectId: projectId }),
config: {
projectId: projectId,
},
} satisfies WalletConfig<WalletConnect, TrustWalletConfig>;
create: (options: WalletOptions) =>
new TrustWallet({
...options,
walletId: "trust",
projectId: config?.projectId,
}),
} satisfies WalletConfig<WalletConnectV2>;
};
+46
View File
@@ -1,5 +1,51 @@
# @thirdweb-dev/react
## 3.13.1
### Patch Changes
- [#1151](https://github.com/thirdweb-dev/js/pull/1151) [`2a0294d8`](https://github.com/thirdweb-dev/js/commit/2a0294d8e67bbc08dcf59c79174a7626deb0e90a) Thanks [@MananTank](https://github.com/MananTank)! - Fix wrong balance in ConnectWallet
- [#1149](https://github.com/thirdweb-dev/js/pull/1149) [`65ecf072`](https://github.com/thirdweb-dev/js/commit/65ecf072eb810eaf850c0af94f3db5af51de8a28) Thanks [@MananTank](https://github.com/MananTank)! - Improve rendering of long network list in ConnectWallet Modal
- [#1144](https://github.com/thirdweb-dev/js/pull/1144) [`9ce3eb6a`](https://github.com/thirdweb-dev/js/commit/9ce3eb6aad957aff38fb4a25383ed17ff58e988f) Thanks [@MananTank](https://github.com/MananTank)! - Remove WalletConfig.config object from wallets
- Updated dependencies [[`2a443365`](https://github.com/thirdweb-dev/js/commit/2a443365bdc3d47d0f41fc895f70256dcde423f5), [`3bf7f375`](https://github.com/thirdweb-dev/js/commit/3bf7f375933cbd7dd8c682a66e8c67bbcb268bf7), [`6a194262`](https://github.com/thirdweb-dev/js/commit/6a19426200297b8da158c7d860d31efcc8c15822), [`16232de9`](https://github.com/thirdweb-dev/js/commit/16232de9eab9966e24e335929b2a3919346af265), [`54cfd6d8`](https://github.com/thirdweb-dev/js/commit/54cfd6d8916c42d87b6aa438e607ce525766b686), [`8687d6ac`](https://github.com/thirdweb-dev/js/commit/8687d6ac3a363eae63eeb1959a953cbcd282d353), [`645b0303`](https://github.com/thirdweb-dev/js/commit/645b0303cc1a9cbb0a0e9cbd67d11c3b865e4584), [`522453fd`](https://github.com/thirdweb-dev/js/commit/522453fd568b8c350141a96f9f1c6d5a3ef74493), [`9a015a23`](https://github.com/thirdweb-dev/js/commit/9a015a23cde09c8ba6c36593a84303ffe409a79a), [`6803c3e9`](https://github.com/thirdweb-dev/js/commit/6803c3e97ca74eed19cd90095afde25b02150d51), [`0cba69ca`](https://github.com/thirdweb-dev/js/commit/0cba69ca40a8cf6f106344247d0082212cd169da), [`56f85e57`](https://github.com/thirdweb-dev/js/commit/56f85e57df84bfa93e3230639c95d12466f8aec7), [`197a6838`](https://github.com/thirdweb-dev/js/commit/197a6838f69ae8b9ad46524e7c469fc757d0a2cb), [`6a91b6a0`](https://github.com/thirdweb-dev/js/commit/6a91b6a0253bab5914d4ebdad951dd1c5d141fbc), [`e32faeb5`](https://github.com/thirdweb-dev/js/commit/e32faeb57a5c2193c40cb6129fab92b84069b12d), [`a5f16b6d`](https://github.com/thirdweb-dev/js/commit/a5f16b6dc50b37920a6e5210b60aa6a1682ceb63), [`b6728603`](https://github.com/thirdweb-dev/js/commit/b6728603972ccd6c95108b25e8562807f0f95e19), [`ed47fd53`](https://github.com/thirdweb-dev/js/commit/ed47fd5310d11323080d984bca18a96fdef3a977), [`9ce3eb6a`](https://github.com/thirdweb-dev/js/commit/9ce3eb6aad957aff38fb4a25383ed17ff58e988f)]:
- @thirdweb-dev/wallets@0.2.26
- @thirdweb-dev/sdk@3.10.21
- @thirdweb-dev/react-core@3.13.1
- @thirdweb-dev/chains@0.1.20
## 3.13.0
### Patch Changes
- [#1115](https://github.com/thirdweb-dev/js/pull/1115) [`b4c95159`](https://github.com/thirdweb-dev/js/commit/b4c95159377dfaa27b4b9625bc9a828b799d0005) Thanks [@nachoiacovino](https://github.com/nachoiacovino)! - Add hooks for smart wallet factory
- [#1116](https://github.com/thirdweb-dev/js/pull/1116) [`356f7aa6`](https://github.com/thirdweb-dev/js/commit/356f7aa6430003bbe8edf9a526bcee77ad5c21ee) Thanks [@MananTank](https://github.com/MananTank)! - - Fix Local wallet connection issue with Safe & Smart Wallet
- Fix Metamask QR connection issue with Safe & Smart Wallet
- [#1118](https://github.com/thirdweb-dev/js/pull/1118) [`9b20fc9a`](https://github.com/thirdweb-dev/js/commit/9b20fc9ad2d303edc31f44fbd2ea3b4dcf35d11e) Thanks [@MananTank](https://github.com/MananTank)! - - Remove chain restriction in paper wallet
- Fix Email validation in Paper and Magic wallet
- [#1114](https://github.com/thirdweb-dev/js/pull/1114) [`2283e71a`](https://github.com/thirdweb-dev/js/commit/2283e71acaaf3d15eb2d6121682f1d2a81eec4f3) Thanks [@adam-maj](https://github.com/adam-maj)! - Update ConnectWallet button with new auth
- Updated dependencies [[`ce36322b`](https://github.com/thirdweb-dev/js/commit/ce36322b383af73905894b73f9409a146359ffb0), [`c60658ed`](https://github.com/thirdweb-dev/js/commit/c60658ed8c94867cca831b0d5535006da5b40aa6), [`aa9e952c`](https://github.com/thirdweb-dev/js/commit/aa9e952cb519a47ed112d2905b1f3787863035b6), [`564eaccf`](https://github.com/thirdweb-dev/js/commit/564eaccf480a81f36db43c782392595a5021e5ac), [`6aee0413`](https://github.com/thirdweb-dev/js/commit/6aee0413439b9ca408879bbb3c38c538c89d01af), [`21627c03`](https://github.com/thirdweb-dev/js/commit/21627c03d1bb1658fee19b12d580faa6c7f048d9), [`2283e71a`](https://github.com/thirdweb-dev/js/commit/2283e71acaaf3d15eb2d6121682f1d2a81eec4f3), [`e93aa70e`](https://github.com/thirdweb-dev/js/commit/e93aa70ef0093a2526404e11b7ddae8fb98c213b), [`51bbd3d1`](https://github.com/thirdweb-dev/js/commit/51bbd3d1bccbb92a1405ea50f6c178c091a90f20), [`9b20fc9a`](https://github.com/thirdweb-dev/js/commit/9b20fc9ad2d303edc31f44fbd2ea3b4dcf35d11e)]:
- @thirdweb-dev/sdk@3.10.20
- @thirdweb-dev/react-core@3.13.0
- @thirdweb-dev/wallets@0.2.25
## 3.12.4
### Patch Changes
- Updated dependencies [[`23d90b3e`](https://github.com/thirdweb-dev/js/commit/23d90b3e779a5bfdb7058b8c51349d9c278fcbce), [`cc56037e`](https://github.com/thirdweb-dev/js/commit/cc56037e64560b9e0fc16eb0ac7cc2e47e2c9fdf)]:
- @thirdweb-dev/sdk@3.10.19
- @thirdweb-dev/react-core@3.12.4
- @thirdweb-dev/wallets@0.2.24
## 3.12.3
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/react",
"version": "3.12.3",
"version": "3.13.1",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
@@ -6,16 +6,11 @@ import {
UseQueryResult,
useQueryClient,
} from "@tanstack/react-query";
import type { PaperSupportedChainId } from "@thirdweb-dev/wallets/evm/connectors/paper";
export function usePaperWallet() {
const connect = useConnect();
return useCallback(
async (options: {
chainId?: PaperSupportedChainId;
clientId: string;
email?: string;
}) => {
async (options: { chainId?: number; clientId: string; email?: string }) => {
const { paperWallet } = await import(
"../../../wallet/wallets/paperWallet"
);
@@ -30,7 +30,7 @@ interface ThirdwebProviderProps<TChains extends Chain[]>
* />
* ```
*/
supportedWallets?: WalletConfig<any, any>[];
supportedWallets?: WalletConfig<any>[];
}
/**
@@ -57,9 +57,7 @@ export const ConnectModal = () => {
const isWrapperConnected = !!wallet?.getPersonalWallet();
const isWrapperScreen =
typeof screen !== "string" &&
"config" in screen &&
!!(screen.config as any).personalWallets;
typeof screen !== "string" && !!screen.personalWallets;
const prevConnectionStatus = useRef(connectionStatus);
@@ -20,7 +20,6 @@ import { Button } from "../../components/buttons";
import { Spinner } from "../../components/Spinner";
import styled from "@emotion/styled";
import { fadeInAnimation } from "../../components/FadeIn";
import type { LoginOptions } from "@thirdweb-dev/auth";
import { LockIcon } from "./icons/LockIcon";
import { Flex } from "../../components/basic";
import { shortenAddress } from "../../evm/utils/addresses";
@@ -42,7 +41,6 @@ type ConnectWalletProps = {
detailsBtn?: () => JSX.Element;
dropdownPosition?: DropDownPosition;
auth?: {
loginOptions?: LoginOptions;
loginOptional?: boolean;
onLogin?: (token: string) => void;
onLogout?: () => void;
@@ -86,7 +84,7 @@ export const ConnectWallet: React.FC<ConnectWalletProps> = (props) => {
const signIn = async () => {
try {
setShowSignatureModal(true);
const token = await login(props.auth?.loginOptions);
const token = await login();
props?.auth?.onLogin?.(token);
} catch (err) {
console.error("failed to log in", err);

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