@swapkit/helpers 1.0.0-rc.98 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,25 +1,33 @@
1
- import type { CosmosWallets, ThorchainWallets } from "@swapkit/toolbox-cosmos";
2
- import type { EVMWallets } from "@swapkit/toolbox-evm";
3
- import type { SubstrateWallets } from "@swapkit/toolbox-substrate";
4
- import type { UTXOWallets } from "@swapkit/toolbox-utxo";
1
+ import type { Eip1193Provider } from "ethers";
5
2
  import type { AssetValue } from "../modules/assetValue";
6
3
  import type { Chain } from "./chains";
7
4
 
5
+ declare global {
6
+ interface WindowEventMap {
7
+ "eip6963:announceProvider": CustomEvent;
8
+ }
9
+ }
10
+
8
11
  export enum WalletOption {
9
- KEYSTORE = "KEYSTORE",
10
- KEEPKEY = "KEEPKEY",
11
- XDEFI = "XDEFI",
12
- METAMASK = "METAMASK",
13
- COINBASE_WEB = "COINBASE_WEB",
12
+ BRAVE = "BRAVE",
14
13
  COINBASE_MOBILE = "COINBASE_MOBILE",
15
- TREZOR = "TREZOR",
16
- TRUSTWALLET_WEB = "TRUSTWALLET_WEB",
17
- LEDGER = "LEDGER",
14
+ COINBASE_WEB = "COINBASE_WEB",
15
+ EIP6963 = "EIP6963",
16
+ EXODUS = "EXODUS",
17
+ KEEPKEY = "KEEPKEY",
18
18
  KEPLR = "KEPLR",
19
+ KEYSTORE = "KEYSTORE",
20
+ LEDGER = "LEDGER",
21
+ METAMASK = "METAMASK",
19
22
  OKX = "OKX",
20
23
  OKX_MOBILE = "OKX_MOBILE",
21
- BRAVE = "BRAVE",
24
+ PHANTOM = "PHANTOM",
25
+ RADIX_WALLET = "RADIX_WALLET",
26
+ TREZOR = "TREZOR",
27
+ TALISMAN = "TALISMAN",
28
+ TRUSTWALLET_WEB = "TRUSTWALLET_WEB",
22
29
  WALLETCONNECT = "WALLETCONNECT",
30
+ XDEFI = "XDEFI",
23
31
  }
24
32
 
25
33
  export enum LedgerErrorCode {
@@ -33,15 +41,32 @@ export type ChainWallet = {
33
41
  address: string;
34
42
  balance: AssetValue[];
35
43
  walletType: WalletOption;
44
+ disconnect?: () => void;
36
45
  };
37
46
 
38
47
  export type EmptyWallet = { [key in Chain]?: unknown };
48
+ export type BaseWallet<T extends EmptyWallet | Record<string, unknown>> = {
49
+ [key in Chain]: ChainWallet & (T extends EmptyWallet ? T[key] : unknown);
50
+ };
51
+
52
+ export type EIP6963ProviderInfo = {
53
+ walletId: string;
54
+ uuid: string;
55
+ name: string;
56
+ icon: string;
57
+ };
39
58
 
40
- export type BaseWallet<T extends EmptyWallet | unknown> = {
41
- // @ts-expect-error
42
- [key in Chain]: ChainWallet & T[key];
59
+ export type EIP6963ProviderDetail = {
60
+ info: EIP6963ProviderInfo;
61
+ provider: Eip1193Provider;
43
62
  };
44
63
 
45
- export type Wallet = BaseWallet<
46
- EVMWallets & CosmosWallets & ThorchainWallets & UTXOWallets & SubstrateWallets
47
- >;
64
+ export type EIP6963Provider = {
65
+ info: EIP6963ProviderInfo;
66
+ provider: Eip1193Provider;
67
+ };
68
+
69
+ // This type represents the structure of an event dispatched by a wallet to announce its presence based on EIP-6963.
70
+ export type EIP6963AnnounceProviderEvent = Event & {
71
+ detail: EIP6963Provider;
72
+ };