/
window.d.ts
153 lines (142 loc) · 4.17 KB
/
window.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
import type {
PublicKey,
SendOptions,
Transaction,
TransactionSignature,
} from "@solana/web3.js";
type ConnectOptions = {
onlyIfTrusted?: boolean;
};
type ExodusEvent = "accountChanged" | "connect" | "disconnect";
type ExodusRequestMethod =
| "connect"
| "disconnect"
| "signTransaction"
| "signAllTransactions"
| "signAndSendTransaction"
| "signMessage"
| "postMessage";
export interface ExodusProvider {
publicKey: PublicKey | null;
isConnected: boolean;
signTransaction: (transaction: Transaction) => Promise<Transaction>;
signAllTransactions: (transactions: Transaction[]) => Promise<Transaction[]>;
connect: (options?: ConnectOptions) => Promise<{ publicKey: PublicKey }>;
disconnect: () => void;
on: (event: ExodusEvent, handler: (args: unknown) => void) => void;
request: (method: ExodusRequestMethod, params: unknown[]) => Promise<unknown>;
isExodus: true;
isMathWallet: undefined;
isPhantom: undefined;
}
type PhantomEvent = "disconnect" | "connect";
type PhantomRequestMethod =
| "connect"
| "disconnect"
| "signTransaction"
| "signAllTransactions";
export interface PhantomProvider {
publicKey?: PublicKey;
isConnected?: boolean;
autoApprove?: boolean;
signTransaction: (transaction: Transaction) => Promise<Transaction>;
signAllTransactions: (transactions: Transaction[]) => Promise<Transaction[]>;
signAndSendTransaction(
transaction: Transaction,
options?: SendOptions
): Promise<{ signature: TransactionSignature }>;
signMessage(message: Uint8Array): Promise<{ signature: Uint8Array }>;
connect: (args?: { onlyIfTrusted: true }) => Promise<void>;
disconnect: () => Promise<void>;
on: (event: PhantomEvent, handler: (args: unknown) => void) => void;
request: (method: PhantomRequestMethod, params: unknown) => Promise<unknown>;
listeners: (event: PhantomEvent) => (() => void)[];
isExodus: undefined;
isMathWallet: undefined;
isPhantom: true;
}
export interface MathWalletProvider {
signTransaction: (transaction: Transaction) => Promise<Transaction>;
signAllTransactions: (transactions: Transaction[]) => Promise<Transaction[]>;
getAccount: () => Promise<string>;
isExodus: undefined;
isMathWallet: true;
isPhantom: undefined;
}
declare global {
interface Window {
solana?:
| ExodusProvider
| MathWalletProvider
| PhantomProvider
| { isExodus?: false; isMathWallet?: false; isPhantom?: false };
exodus?: {
solana: ExodusProvider;
};
solflare?: PhantomProvider & {
isSolflare?: boolean;
};
sollet?: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
glowSolana?: {
signAndSendTransaction(
transaction: {
serialize(): {
toString(encoding: "base64"): string;
};
},
network?: "devnet" | "mainnet"
): Promise<{ signature: TransactionSignature }>;
};
solong?: {
signAllTransactions?: (txs: Transaction[]) => Promise<Transaction[]>;
signTransaction: (tx: Transaction) => Promise<Transaction>;
selectAccount: () => Promise<string>;
};
coin98?: {
sol: {
request: (args: {
method: string;
params?: unknown[];
}) => Promise<unknown>;
disconnect: () => void;
};
};
clover_solana?: {
signAllTransactions?: (txs: Transaction[]) => Promise<Transaction[]>;
signTransaction: (tx: Transaction) => Promise<Transaction>;
getAccount: () => Promise<string>;
};
Slope?: {
new (): {
connect(): Promise<{
msg: string;
data: {
publicKey?: string;
};
}>;
disconnect(): Promise<{ msg: string }>;
signTransaction(message: string): Promise<{
msg: string;
data: {
publicKey?: string;
signature?: string;
};
}>;
signAllTransactions(messages: string[]): Promise<{
msg: string;
data: {
publicKey?: string;
signatures?: string[];
};
}>;
};
};
huobiWallet?: {
isHuobiWallet?: boolean;
};
braveSolana?: {
isBraveWallet?: boolean;
};
}
}