-
Notifications
You must be signed in to change notification settings - Fork 5
/
types.ts
51 lines (44 loc) · 1.79 KB
/
types.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
import { PublicKey, Transaction, VersionedTransaction, SendOptions } from '@solana/web3.js';
// import { SolanaSignInInput } from "@solana/wallet-standard-features";
type DisplayEncoding = 'utf8' | 'hex';
type PhantomEvent = 'connect' | 'disconnect' | 'accountChanged';
type PhantomRequestMethod =
| 'connect'
| 'disconnect'
| 'signAndSendTransaction'
| 'signAndSendTransactionV0'
| 'signAndSendTransactionV0WithLookupTable'
| 'signTransaction'
| 'signAllTransactions'
| 'signMessage';
interface ConnectOpts {
onlyIfTrusted: boolean;
}
export interface Provider {
publicKey: PublicKey | null;
isConnected: boolean | null;
signAndSendTransaction: (
transaction: Transaction | VersionedTransaction,
opts?: SendOptions
) => Promise<{ signature: string; publicKey: PublicKey }>;
signTransaction: (transaction: Transaction | VersionedTransaction) => Promise<Transaction | VersionedTransaction>;
signAllTransactions: (
transactions: (Transaction | VersionedTransaction)[]
) => Promise<(Transaction | VersionedTransaction)[]>;
signMessage: (message: Uint8Array | string, display?: DisplayEncoding) => Promise<any>;
// signIn: (signInData: SolanaSignInInput) => Promise<{
// address: PublicKey, signedMessage: Uint8Array, signature: Buffer
// }>;
connect: (opts?: Partial<ConnectOpts>) => Promise<{ publicKey: PublicKey }>;
disconnect: () => Promise<void>;
on: (event: PhantomEvent, handler: (args: any) => void) => void;
request: (method: PhantomRequestMethod, params: any) => Promise<unknown>;
}
export type Status = 'success' | 'warning' | 'error' | 'info';
export interface TLog {
status: Status;
method?: PhantomRequestMethod | Extract<PhantomEvent, 'accountChanged'>;
confirmation?: {signature: string, link: string};
message: string;
messageTwo?: string;
}