Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
34be385a5c | ||
|
|
79c9e130fd | ||
|
|
9c884e2f55 |
@@ -1,5 +1,12 @@
|
||||
# @thirdweb-dev/auth
|
||||
|
||||
## 4.1.46
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`79c9e13`](https://github.com/thirdweb-dev/js/commit/79c9e130fdc6e1f7de1486894a5ac3e6d6776fa4)]:
|
||||
- @thirdweb-dev/wallets@2.4.24
|
||||
|
||||
## 4.1.45
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/auth",
|
||||
"version": "4.1.45",
|
||||
"version": "4.1.46",
|
||||
"main": "dist/thirdweb-dev-auth.cjs.js",
|
||||
"module": "dist/thirdweb-dev-auth.esm.js",
|
||||
"browser": {
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
# thirdweb
|
||||
|
||||
## 0.13.54
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`79c9e13`](https://github.com/thirdweb-dev/js/commit/79c9e130fdc6e1f7de1486894a5ac3e6d6776fa4)]:
|
||||
- @thirdweb-dev/wallets@2.4.24
|
||||
- @thirdweb-dev/auth@4.1.46
|
||||
|
||||
## 0.13.53
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "thirdweb",
|
||||
"main": "dist/cli/index.js",
|
||||
"version": "0.13.53",
|
||||
"version": "0.13.54",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/cli",
|
||||
"author": "thirdweb eng <[email protected]>",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
# @thirdweb-dev/react-core
|
||||
|
||||
## 4.4.22
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#2497](https://github.com/thirdweb-dev/js/pull/2497) [`79c9e13`](https://github.com/thirdweb-dev/js/commit/79c9e130fdc6e1f7de1486894a5ac3e6d6776fa4) Thanks [@makoshan](https://github.com/makoshan)! - Add imToken Wallet
|
||||
|
||||
- Updated dependencies [[`79c9e13`](https://github.com/thirdweb-dev/js/commit/79c9e130fdc6e1f7de1486894a5ac3e6d6776fa4)]:
|
||||
- @thirdweb-dev/wallets@2.4.24
|
||||
- @thirdweb-dev/auth@4.1.46
|
||||
|
||||
## 4.4.21
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/react-core",
|
||||
"version": "4.4.21",
|
||||
"version": "4.4.22",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-core",
|
||||
"author": "thirdweb eng <[email protected]>",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -8,6 +8,7 @@ import type {
|
||||
CryptoDefiWallet,
|
||||
EmbeddedWallet,
|
||||
FrameWallet,
|
||||
ImTokenWallet,
|
||||
LocalWallet,
|
||||
MagicEdenWallet,
|
||||
MagicLink,
|
||||
@@ -41,6 +42,7 @@ export type WalletIdToWalletTypeMap = {
|
||||
rainbowWallet: RainbowWallet;
|
||||
blocto: BloctoWallet;
|
||||
frame: FrameWallet;
|
||||
imToken: ImTokenWallet;
|
||||
localWallet: LocalWallet;
|
||||
magicLink: MagicLink;
|
||||
paper: PaperWallet;
|
||||
@@ -57,7 +59,7 @@ export type WalletIdToWalletTypeMap = {
|
||||
cryptoDefiWallet: CryptoDefiWallet;
|
||||
rabby: RabbyWallet;
|
||||
xdefi: XDEFIWallet;
|
||||
magicEden: MagicEdenWallet
|
||||
magicEden: MagicEdenWallet;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Binary file not shown.
@@ -1,5 +1,7 @@
|
||||
# @thirdweb-dev/react-native-compat
|
||||
|
||||
## 0.7.19
|
||||
|
||||
## 0.7.18
|
||||
|
||||
## 0.7.17
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/react-native-compat",
|
||||
"description": "Shims for Thirdweb in React Native Projects",
|
||||
"version": "0.7.18",
|
||||
"version": "0.7.19",
|
||||
"author": "thirdweb eng <[email protected]>",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native-compat",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
# @thirdweb-dev/react-native
|
||||
|
||||
## 0.7.19
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`79c9e13`](https://github.com/thirdweb-dev/js/commit/79c9e130fdc6e1f7de1486894a5ac3e6d6776fa4)]:
|
||||
- @thirdweb-dev/wallets@2.4.24
|
||||
- @thirdweb-dev/react-core@4.4.22
|
||||
|
||||
## 0.7.18
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/react-native",
|
||||
"version": "0.7.18",
|
||||
"version": "0.7.19",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native",
|
||||
"author": "thirdweb eng <[email protected]>",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
Binary file not shown.
@@ -1,5 +1,15 @@
|
||||
# @thirdweb-dev/react
|
||||
|
||||
## 4.4.22
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#2497](https://github.com/thirdweb-dev/js/pull/2497) [`79c9e13`](https://github.com/thirdweb-dev/js/commit/79c9e130fdc6e1f7de1486894a5ac3e6d6776fa4) Thanks [@makoshan](https://github.com/makoshan)! - Add imToken Wallet
|
||||
|
||||
- Updated dependencies [[`79c9e13`](https://github.com/thirdweb-dev/js/commit/79c9e130fdc6e1f7de1486894a5ac3e6d6776fa4)]:
|
||||
- @thirdweb-dev/wallets@2.4.24
|
||||
- @thirdweb-dev/react-core@4.4.22
|
||||
|
||||
## 4.4.21
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/react",
|
||||
"version": "4.4.21",
|
||||
"version": "4.4.22",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react",
|
||||
"author": "thirdweb eng <[email protected]>",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -111,4 +111,5 @@ export {
|
||||
CryptoDefiWallet,
|
||||
RabbyWallet,
|
||||
Coin98Wallet,
|
||||
ImTokenWallet,
|
||||
} from "@thirdweb-dev/wallets";
|
||||
|
||||
@@ -171,6 +171,7 @@ export function enDefault(): ThirdwebLocale {
|
||||
xdefiWallet: extensionAndQRScanScreens("XDEFI"),
|
||||
rainbowWallet: extensionAndQRScanScreens("Rainbow"),
|
||||
trustWallet: extensionAndQRScanScreens("Trust"),
|
||||
imTokenWallet: extensionAndQRScanScreens("imToken"),
|
||||
zerionWallet: extensionAndQRScanScreens("Zerion"),
|
||||
coreWallet: extensionAndQRScanScreens("Core"),
|
||||
oneKeyWallet: extensionAndQRScanScreens("OneKey"),
|
||||
|
||||
@@ -176,6 +176,7 @@ export function esDefault(): ThirdwebLocale {
|
||||
xdefiWallet: extensionAndQRScanScreens("XDEFI"),
|
||||
rainbowWallet: extensionAndQRScanScreens("Rainbow"),
|
||||
trustWallet: extensionAndQRScanScreens("Trust"),
|
||||
imTokenWallet: extensionAndQRScanScreens("imToken"),
|
||||
zerionWallet: extensionAndQRScanScreens("Zerion"),
|
||||
oneKeyWallet: extensionAndQRScanScreens("OneKey"),
|
||||
cryptoDefiWallet: extensionAndQRScanScreens("Crypto Defi"),
|
||||
|
||||
@@ -176,6 +176,7 @@ export function jaDefault(): ThirdwebLocale {
|
||||
xdefiWallet: extensionAndQRScanScreens("XDEFI"),
|
||||
rainbowWallet: extensionAndQRScanScreens("Rainbow"),
|
||||
trustWallet: extensionAndQRScanScreens("Trust"),
|
||||
imTokenWallet: extensionAndQRScanScreens("imToken"),
|
||||
zerionWallet: extensionAndQRScanScreens("Zerion"),
|
||||
oneKeyWallet: extensionAndQRScanScreens("OneKey"),
|
||||
cryptoDefiWallet: extensionAndQRScanScreens("Crypto Defi"),
|
||||
|
||||
@@ -176,6 +176,7 @@ export function tlDefault(): ThirdwebLocale {
|
||||
xdefiWallet: extensionAndQRScanScreens("XDEFI"),
|
||||
rainbowWallet: extensionAndQRScanScreens("Rainbow"),
|
||||
trustWallet: extensionAndQRScanScreens("Trust"),
|
||||
imTokenWallet: extensionAndQRScanScreens("imToken"),
|
||||
zerionWallet: extensionAndQRScanScreens("Zerion"),
|
||||
coreWallet: extensionAndQRScanScreens("Core"),
|
||||
oneKeyWallet: extensionAndQRScanScreens("OneKey"),
|
||||
|
||||
@@ -183,6 +183,7 @@ export type ThirdwebLocale = {
|
||||
getStartedScreen: { instruction: string };
|
||||
scanScreen: { instruction: string };
|
||||
};
|
||||
trustWallet: ExtensionAndQRScreensLocale;
|
||||
localWallet: {
|
||||
confirmPasswordLabel: string;
|
||||
createScreen: {
|
||||
@@ -302,7 +303,7 @@ export type ThirdwebLocale = {
|
||||
title: string;
|
||||
};
|
||||
};
|
||||
trustWallet: ExtensionAndQRScreensLocale;
|
||||
imTokenWallet: ExtensionAndQRScreensLocale;
|
||||
walletConnect: { scanInstruction: string };
|
||||
zerionWallet: ExtensionAndQRScreensLocale;
|
||||
};
|
||||
|
||||
@@ -107,6 +107,11 @@ export {
|
||||
type Coin98WalletConfigOptions,
|
||||
} from "./wallet/wallets/coin98/coin98Wallet";
|
||||
|
||||
export {
|
||||
imTokenWallet,
|
||||
type ImTokenWalletConfigOptions,
|
||||
} from "./wallet/wallets/imtoken/imTokenWallet";
|
||||
|
||||
// theming
|
||||
export { darkTheme, lightTheme } from "./design-system/index";
|
||||
export type { Theme, ThemeOverrides } from "./design-system/index";
|
||||
|
||||
@@ -12,6 +12,7 @@ export function useInstalledWallets() {
|
||||
let isCoinbaseWalletInstalled = false;
|
||||
let isZerionWalletInstalled = false;
|
||||
let isTrustWalletInstalled = false;
|
||||
let isImTokenInstalled = false;
|
||||
|
||||
const window_: Window | undefined = globalThis?.window;
|
||||
if (assertWindowEthereum(window_)) {
|
||||
@@ -19,6 +20,7 @@ export function useInstalledWallets() {
|
||||
isCoinbaseWalletInstalled = !!getInjectedCoinbaseProvider();
|
||||
isZerionWalletInstalled = !!window_.ethereum?.isZerion;
|
||||
isTrustWalletInstalled = !!window_.ethereum?.isTrust;
|
||||
isImTokenInstalled = !!window_.ethereum?.isToken;
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -26,5 +28,6 @@ export function useInstalledWallets() {
|
||||
coinbaseWallet: isCoinbaseWalletInstalled,
|
||||
trustWallet: isTrustWalletInstalled,
|
||||
zerionWallet: isZerionWalletInstalled,
|
||||
imtokenWallet: isImTokenInstalled,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
import type {
|
||||
WalletOptions,
|
||||
WalletConfig,
|
||||
ConnectUIProps,
|
||||
} from "@thirdweb-dev/react-core";
|
||||
import { ImTokenWallet, assertWindowEthereum } from "@thirdweb-dev/wallets";
|
||||
import { useTWLocale } from "../../../evm/providers/locale-provider";
|
||||
import { ExtensionOrWCConnectionUI } from "../_common/ExtensionORWCConnectionUI";
|
||||
|
||||
const imTokenWalletUris = {
|
||||
ios: "https://itunes.apple.com/us/app/imtoken2/id1384798940",
|
||||
android: "https://play.google.com/store/apps/details?id=im.token.app",
|
||||
};
|
||||
|
||||
export type ImTokenWalletConfigOptions = {
|
||||
projectId?: string;
|
||||
recommended?: boolean;
|
||||
};
|
||||
|
||||
export const imTokenWallet = (
|
||||
options?: ImTokenWalletConfigOptions,
|
||||
): WalletConfig<ImTokenWallet> => {
|
||||
return {
|
||||
id: ImTokenWallet.id,
|
||||
recommended: options?.recommended,
|
||||
meta: {
|
||||
...ImTokenWallet.meta,
|
||||
iconURL:
|
||||
"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iODAiIGhlaWdodD0iODAiIHZpZXdCb3g9IjAgMCA4MCA4MCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh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T0iNS4zMTI1IiB4Mj0iMi44NzI0MSIgeTI9Ijc3LjY3NDciIGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIj4KPHN0b3Agc3RvcC1jb2xvcj0iIzExQzREMSIvPgo8c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiMwMDYyQUQiLz4KPC9saW5lYXJHcmFkaWVudD4KPGNsaXBQYXRoIGlkPSJjbGlwMF8yMjJfNDc4MyI+CjxyZWN0IHdpZHRoPSI4MCIgaGVpZ2h0PSI4MCIgZmlsbD0id2hpdGUiLz4KPC9jbGlwUGF0aD4KPC9kZWZzPgo8L3N2Zz4=",
|
||||
},
|
||||
create: (walletOptions: WalletOptions) => {
|
||||
const wallet = new ImTokenWallet({
|
||||
...walletOptions,
|
||||
projectId: options?.projectId,
|
||||
qrcode: false,
|
||||
});
|
||||
|
||||
return wallet;
|
||||
},
|
||||
connectUI: ConnectUI,
|
||||
isInstalled: isInstalled,
|
||||
};
|
||||
};
|
||||
|
||||
function isInstalled() {
|
||||
if (assertWindowEthereum(globalThis.window)) {
|
||||
return !!globalThis.window.ethereum.isImToken;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function ConnectUI(props: ConnectUIProps<ImTokenWallet>) {
|
||||
const locale = useTWLocale();
|
||||
return (
|
||||
<ExtensionOrWCConnectionUI
|
||||
connect={props.connect}
|
||||
connected={props.connected}
|
||||
createWalletInstance={props.createWalletInstance}
|
||||
goBack={props.goBack}
|
||||
meta={props.walletConfig.meta}
|
||||
setConnectedWallet={(w) => props.setConnectedWallet(w as ImTokenWallet)}
|
||||
setConnectionStatus={props.setConnectionStatus}
|
||||
supportedWallets={props.supportedWallets}
|
||||
walletConnectUris={{
|
||||
ios: imTokenWalletUris.ios,
|
||||
android: imTokenWalletUris.android,
|
||||
other: imTokenWalletUris.android,
|
||||
}}
|
||||
walletLocale={locale.wallets.imTokenWallet}
|
||||
isInstalled={isInstalled}
|
||||
/>
|
||||
);
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,15 @@
|
||||
# @thirdweb-dev/unity-js-bridge
|
||||
|
||||
## 0.4.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#2501](https://github.com/thirdweb-dev/js/pull/2501) [`9c884e2`](https://github.com/thirdweb-dev/js/commit/9c884e2f55f1d096555c1fcf65bc850684d258c9) Thanks [@0xFirekeeper](https://github.com/0xFirekeeper)! - [Unity] Expose additional WC QR Options
|
||||
|
||||
- Updated dependencies [[`79c9e13`](https://github.com/thirdweb-dev/js/commit/79c9e130fdc6e1f7de1486894a5ac3e6d6776fa4)]:
|
||||
- @thirdweb-dev/wallets@2.4.24
|
||||
- @thirdweb-dev/auth@4.1.46
|
||||
|
||||
## 0.4.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/unity-js-bridge",
|
||||
"version": "0.4.11",
|
||||
"version": "0.4.12",
|
||||
"main": "dist/thirdweb-unity-bridge.js",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/unity-js-bridge",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -151,7 +151,7 @@ class ThirdwebBridge implements TWBridge {
|
||||
}
|
||||
(globalThis as any).X_SDK_NAME = "UnitySDK_WebGL";
|
||||
(globalThis as any).X_SDK_PLATFORM = "unity";
|
||||
(globalThis as any).X_SDK_VERSION = "4.7.10";
|
||||
(globalThis as any).X_SDK_VERSION = "4.7.11";
|
||||
(globalThis as any).X_SDK_OS = browser?.os ?? "unknown";
|
||||
}
|
||||
this.initializedChain = chain;
|
||||
@@ -221,8 +221,18 @@ class ThirdwebBridge implements TWBridge {
|
||||
chains: supportedChains,
|
||||
clientId: sdkOptions.clientId,
|
||||
qrModalOptions: {
|
||||
enableExplorer:
|
||||
sdkOptions.wallet?.walletConnectEnableExplorer ?? false,
|
||||
explorerRecommendedWalletIds:
|
||||
sdkOptions.wallet?.walletConnectExplorerRecommendedWalletIds,
|
||||
sdkOptions.wallet?.walletConnectExplorerRecommendedWalletIds ??
|
||||
undefined,
|
||||
walletImages:
|
||||
sdkOptions.wallet?.walletConnectWalletImages ?? undefined,
|
||||
desktopWallets:
|
||||
sdkOptions.wallet?.walletConnectDesktopWallets ?? undefined,
|
||||
mobileWallets:
|
||||
sdkOptions.wallet?.walletConnectMobileWallets ?? undefined,
|
||||
themeMode: sdkOptions.wallet?.walletConnectThemeMode ?? undefined,
|
||||
},
|
||||
});
|
||||
break;
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @thirdweb-dev/wallets
|
||||
|
||||
## 2.4.24
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#2497](https://github.com/thirdweb-dev/js/pull/2497) [`79c9e13`](https://github.com/thirdweb-dev/js/commit/79c9e130fdc6e1f7de1486894a5ac3e6d6776fa4) Thanks [@makoshan](https://github.com/makoshan)! - Add imToken Wallet
|
||||
|
||||
## 2.4.23
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"main": "dist/thirdweb-dev-wallets-evm-connectors-imtoken.cjs.js",
|
||||
"module": "dist/thirdweb-dev-wallets-evm-connectors-imtoken.esm.js",
|
||||
"browser": {
|
||||
"./dist/thirdweb-dev-wallets-evm-connectors-imtoken.esm.js": "./dist/thirdweb-dev-wallets-evm-connectors-imtoken.browser.esm.js"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"main": "dist/thirdweb-dev-wallets-evm-wallets-imtoken.cjs.js",
|
||||
"module": "dist/thirdweb-dev-wallets-evm-wallets-imtoken.esm.js",
|
||||
"browser": {
|
||||
"./dist/thirdweb-dev-wallets-evm-wallets-imtoken.esm.js": "./dist/thirdweb-dev-wallets-evm-wallets-imtoken.browser.esm.js"
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/wallets",
|
||||
"version": "2.4.23",
|
||||
"version": "2.4.24",
|
||||
"main": "dist/thirdweb-dev-wallets.cjs.js",
|
||||
"module": "dist/thirdweb-dev-wallets.esm.js",
|
||||
"browser": {
|
||||
@@ -147,6 +147,13 @@
|
||||
},
|
||||
"default": "./evm/wallets/gcp-kms/dist/thirdweb-dev-wallets-evm-wallets-gcp-kms.cjs.js"
|
||||
},
|
||||
"./evm/wallets/imtoken": {
|
||||
"module": {
|
||||
"browser": "./evm/wallets/imtoken/dist/thirdweb-dev-wallets-evm-wallets-imtoken.browser.esm.js",
|
||||
"default": "./evm/wallets/imtoken/dist/thirdweb-dev-wallets-evm-wallets-imtoken.esm.js"
|
||||
},
|
||||
"default": "./evm/wallets/imtoken/dist/thirdweb-dev-wallets-evm-wallets-imtoken.cjs.js"
|
||||
},
|
||||
"./evm/wallets/phantom": {
|
||||
"module": {
|
||||
"browser": "./evm/wallets/phantom/dist/thirdweb-dev-wallets-evm-wallets-phantom.browser.esm.js",
|
||||
@@ -336,6 +343,13 @@
|
||||
},
|
||||
"default": "./evm/wallets/embedded-wallet/dist/thirdweb-dev-wallets-evm-wallets-embedded-wallet.cjs.js"
|
||||
},
|
||||
"./evm/connectors/imtoken": {
|
||||
"module": {
|
||||
"browser": "./evm/connectors/imtoken/dist/thirdweb-dev-wallets-evm-connectors-imtoken.browser.esm.js",
|
||||
"default": "./evm/connectors/imtoken/dist/thirdweb-dev-wallets-evm-connectors-imtoken.esm.js"
|
||||
},
|
||||
"default": "./evm/connectors/imtoken/dist/thirdweb-dev-wallets-evm-connectors-imtoken.cjs.js"
|
||||
},
|
||||
"./evm/connectors/phantom": {
|
||||
"module": {
|
||||
"browser": "./evm/connectors/phantom/dist/thirdweb-dev-wallets-evm-connectors-phantom.browser.esm.js",
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
import { InjectedConnector, InjectedConnectorOptions } from "../injected";
|
||||
import { assertWindowEthereum } from "../../utils/assertWindowEthereum";
|
||||
import { Ethereum } from "../injected/types";
|
||||
import type { Chain } from "@thirdweb-dev/chains";
|
||||
import { AsyncStorage } from "../../../core/AsyncStorage";
|
||||
|
||||
type ImTokenConnectorConstructorArg = {
|
||||
chains?: Chain[];
|
||||
connectorStorage: AsyncStorage;
|
||||
options?: InjectedConnectorOptions;
|
||||
};
|
||||
|
||||
export class ImTokenConnector extends InjectedConnector {
|
||||
constructor(arg: ImTokenConnectorConstructorArg) {
|
||||
const defaultOptions = {
|
||||
name: "imToken",
|
||||
getProvider() {
|
||||
function getReady(ethereum?: Ethereum) {
|
||||
const isToken = !!ethereum?.isToken;
|
||||
if (!isToken) {
|
||||
return;
|
||||
}
|
||||
return ethereum;
|
||||
}
|
||||
|
||||
if (typeof window === "undefined") {
|
||||
return;
|
||||
}
|
||||
if (assertWindowEthereum(globalThis.window)) {
|
||||
if (globalThis.window.ethereum?.providers) {
|
||||
return globalThis.window.ethereum.providers.find(getReady);
|
||||
}
|
||||
|
||||
return getReady(globalThis.window.ethereum);
|
||||
}
|
||||
},
|
||||
};
|
||||
const options = {
|
||||
...defaultOptions,
|
||||
...arg.options,
|
||||
};
|
||||
super({
|
||||
chains: arg.chains,
|
||||
options,
|
||||
connectorStorage: arg.connectorStorage,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -56,6 +56,8 @@ type InjectedProviderFlags = {
|
||||
isDefiWallet?: true;
|
||||
isRabbyWallet?: true;
|
||||
isCoin98Wallet?: true;
|
||||
// imToken
|
||||
isToken?: true;
|
||||
};
|
||||
type InjectedProviders = InjectedProviderFlags & {
|
||||
isMetaMask: true;
|
||||
|
||||
@@ -5,6 +5,7 @@ export const walletIds = {
|
||||
coreWallet: "coreWallet",
|
||||
cryptoDefiWallet: "cryptoDefiWallet",
|
||||
frame: "frame",
|
||||
imtoken: "imToken",
|
||||
localWallet: "localWallet",
|
||||
magicLink: "magicLink",
|
||||
metamask: "metamask",
|
||||
|
||||
@@ -32,6 +32,7 @@ export * from "./wallets/coinbase-wallet";
|
||||
export * from "./wallets/embedded-wallet";
|
||||
export * from "./wallets/ethers";
|
||||
export * from "./wallets/frame";
|
||||
export * from "./wallets/imtoken";
|
||||
export * from "./wallets/injected";
|
||||
export * from "./wallets/local-wallet";
|
||||
export * from "./wallets/signer";
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
import type { WalletConnectConnector as WalletConnectConnectorType } from "../connectors/wallet-connect";
|
||||
import type { QRModalOptions } from "../connectors/wallet-connect/qrModalOptions";
|
||||
import { Connector, WagmiAdapter } from "../interfaces/connector";
|
||||
import { assertWindowEthereum } from "../utils/assertWindowEthereum";
|
||||
import { AbstractClientWallet, WalletOptions } from "./base";
|
||||
import type { ImTokenConnector as ImTokenConnectorType } from "../connectors/imtoken";
|
||||
import { walletIds } from "../constants/walletIds";
|
||||
import { TW_WC_PROJECT_ID } from "../constants/wc";
|
||||
|
||||
type ImTokenAdditionalOptions = {
|
||||
qrcode?: boolean;
|
||||
projectId?: string;
|
||||
qrModalOptions?: QRModalOptions;
|
||||
};
|
||||
|
||||
export type ImTokenWalletOptions = WalletOptions<ImTokenAdditionalOptions>;
|
||||
|
||||
type ConnectWithQrCodeArgs = {
|
||||
chainId?: number;
|
||||
onQrCodeUri: (uri: string) => void;
|
||||
onConnected: (accountAddress: string) => void;
|
||||
};
|
||||
|
||||
export class ImTokenWallet extends AbstractClientWallet<ImTokenAdditionalOptions> {
|
||||
connector?: Connector;
|
||||
walletConnectConnector?: WalletConnectConnectorType;
|
||||
imtokenConnector?: ImTokenConnectorType;
|
||||
isInjected: boolean;
|
||||
static id = walletIds.imtoken as string;
|
||||
|
||||
public get walletName() {
|
||||
return "imToken Wallet" as const;
|
||||
}
|
||||
|
||||
constructor(options: ImTokenWalletOptions) {
|
||||
super(ImTokenWallet.id, options);
|
||||
|
||||
if (assertWindowEthereum(globalThis.window)) {
|
||||
this.isInjected = !!globalThis.window.ethereum?.isImToken;
|
||||
} else {
|
||||
this.isInjected = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected async getConnector(): Promise<Connector> {
|
||||
if (!this.connector) {
|
||||
if (this.isInjected) {
|
||||
// import the connector dynamically
|
||||
const { ImTokenConnector } = await import("../connectors/imtoken");
|
||||
const imtokenConnector = new ImTokenConnector({
|
||||
chains: this.chains,
|
||||
connectorStorage: this.walletStorage,
|
||||
options: {
|
||||
shimDisconnect: true,
|
||||
},
|
||||
});
|
||||
|
||||
this.imtokenConnector = imtokenConnector;
|
||||
|
||||
this.connector = new WagmiAdapter(imtokenConnector);
|
||||
} else {
|
||||
const { WalletConnectConnector } = await import(
|
||||
"../connectors/wallet-connect"
|
||||
);
|
||||
|
||||
const walletConnectConnector = new WalletConnectConnector({
|
||||
chains: this.chains,
|
||||
options: {
|
||||
projectId: this.options?.projectId || TW_WC_PROJECT_ID, // TODO,
|
||||
storage: this.walletStorage,
|
||||
qrcode: this.options?.qrcode,
|
||||
dappMetadata: this.dappMetadata,
|
||||
qrModalOptions: this.options?.qrModalOptions,
|
||||
},
|
||||
});
|
||||
|
||||
walletConnectConnector.getProvider().then((provider) => {
|
||||
provider.signer.client.on("session_request_sent", () => {
|
||||
this.emit("wc_session_request_sent");
|
||||
});
|
||||
});
|
||||
|
||||
// need to save this for getting the QR code URI
|
||||
this.walletConnectConnector = walletConnectConnector;
|
||||
this.connector = new WagmiAdapter(walletConnectConnector);
|
||||
}
|
||||
}
|
||||
|
||||
return this.connector;
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect to the wallet using a QR code.
|
||||
* You can use this method to display a QR code. The user can scan this QR code using the Trust Wallet mobile app to connect to your dapp.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* wallet.connectWithQrCode({
|
||||
* chainId: 1,
|
||||
* onQrCodeUri(qrCodeUri) {
|
||||
* // render the QR code with `qrCodeUri`
|
||||
* },
|
||||
* onConnected(accountAddress) {
|
||||
* // update UI to show connected state
|
||||
* },
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* @param options -
|
||||
* The options object contains the following properties/method:
|
||||
*
|
||||
* ### chainId (optional)
|
||||
* If provided, wallet will prompt the user to switch to the network with the given `chainId` after connecting.
|
||||
*
|
||||
* ### onQrCodeUri
|
||||
* A callback to get the QR code URI to display to the user.
|
||||
*
|
||||
* ### onConnected
|
||||
* A callback that is called when the user has connected their wallet using the QR code.
|
||||
*/
|
||||
async connectWithQrCode(options: ConnectWithQrCodeArgs) {
|
||||
await this.getConnector();
|
||||
const wcConnector = this.walletConnectConnector;
|
||||
|
||||
if (!wcConnector) {
|
||||
throw new Error("WalletConnect connector not found");
|
||||
}
|
||||
|
||||
const wcProvider = await wcConnector.getProvider();
|
||||
|
||||
// set a listener for display_uri event
|
||||
wcProvider.on("display_uri", (uri) => {
|
||||
options.onQrCodeUri(uri);
|
||||
});
|
||||
|
||||
// trigger connect flow
|
||||
this.connect({ chainId: options.chainId }).then(options.onConnected);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Reference in New Issue
Block a user