@swapkit/helpers
Advanced tools
Comparing version 1.0.0-rc.100 to 1.0.0-rc.101
@@ -8,8 +8,8 @@ { | ||
"devDependencies": { | ||
"@swapkit/tokens": "1.0.0-rc.51", | ||
"bun-types": "1.1.2", | ||
"@swapkit/tokens": "1.0.0-rc.52", | ||
"bun-types": "1.1.8", | ||
"ethers": "6.11.1" | ||
}, | ||
"peerDependencies": { | ||
"@swapkit/tokens": "1.0.0-rc.51", | ||
"@swapkit/tokens": "1.0.0-rc.52", | ||
"ky": "1.2.3" | ||
@@ -40,3 +40,3 @@ }, | ||
"types": "./src/index.ts", | ||
"version": "1.0.0-rc.100" | ||
"version": "1.0.0-rc.101" | ||
} |
import type { BrowserProvider } from "ethers"; | ||
import { ChainId, WalletOption } from "../types"; | ||
import { | ||
ChainId, | ||
type EIP6963AnnounceProviderEvent, | ||
type EIP6963Provider, | ||
WalletOption, | ||
} from "../types"; | ||
@@ -145,3 +150,3 @@ export type EthereumWindowProvider = BrowserProvider & { | ||
const listWeb3EVMWallets = () => { | ||
export const listWeb3EVMWallets = () => { | ||
const metamaskEnabled = window?.ethereum && !window.ethereum?.isBraveWallet; | ||
@@ -168,2 +173,20 @@ // @ts-ignore that should be implemented in xdefi and hooked up via swapkit core | ||
export function getEIP6963Wallets() { | ||
const providers: EIP6963Provider[] = []; | ||
function onAnnouncement(event: EIP6963AnnounceProviderEvent) { | ||
if (providers.map((p) => p.info.uuid).includes(event.detail.info.uuid)) return; | ||
providers.push(event.detail); | ||
} | ||
window.addEventListener("eip6963:announceProvider", onAnnouncement); | ||
window.dispatchEvent(new Event("eip6963:requestProvider")); | ||
function removeEIP6963EventListener() { | ||
window.removeEventListener("eip6963:announceProvider", onAnnouncement); | ||
} | ||
return { providers, removeEIP6963EventListener }; | ||
} | ||
export const okxMobileEnabled = () => { | ||
@@ -170,0 +193,0 @@ const ua = navigator.userAgent; |
@@ -5,5 +5,12 @@ import type { CosmosWallets, ThorchainWallets } from "@swapkit/toolbox-cosmos"; | ||
import type { UTXOWallets } from "@swapkit/toolbox-utxo"; | ||
import type { Eip1193Provider } from "ethers"; | ||
import type { AssetValue } from "../modules/assetValue"; | ||
import type { Chain } from "./chains"; | ||
declare global { | ||
interface WindowEventMap { | ||
"eip6963:announceProvider": CustomEvent; | ||
} | ||
} | ||
export enum WalletOption { | ||
@@ -24,2 +31,4 @@ KEYSTORE = "KEYSTORE", | ||
WALLETCONNECT = "WALLETCONNECT", | ||
EIP6963 = "EIP6963", | ||
EXODUS = "EXODUS", | ||
} | ||
@@ -50,1 +59,23 @@ | ||
>; | ||
export type EIP6963ProviderInfo = { | ||
walletId: string; | ||
uuid: string; | ||
name: string; | ||
icon: string; | ||
}; | ||
export type EIP6963ProviderDetail = { | ||
info: EIP6963ProviderInfo; | ||
provider: Eip1193Provider; | ||
}; | ||
export type EIP6963Provider = { | ||
info: EIP6963ProviderInfo; | ||
provider: Eip1193Provider; | ||
}; | ||
// This type represents the structure of an event dispatched by a wallet to announce its presence based on EIP-6963. | ||
export type EIP6963AnnounceProviderEvent = Event & { | ||
detail: EIP6963Provider; | ||
}; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
409259
6711