@phantom/browser-sdk 0.0.9 → 0.0.10
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.
- package/README.md +7 -0
- package/dist/auto-confirm/index.d.ts +4 -31
- package/dist/extension/index.d.ts +10 -0
- package/dist/extension/index.js +50 -0
- package/dist/extension/index.mjs +25 -0
- package/dist/index-52a9bded.d.ts +182 -0
- package/dist/index.d.ts +3 -16
- package/dist/solana/index.d.ts +4 -133
- package/package.json +9 -4
package/README.md
CHANGED
|
@@ -73,6 +73,13 @@ Once the `phantom.solana` object is initialized, you can access the following me
|
|
|
73
73
|
- `signAndSendTransaction(transaction: Transaction): Promise<{ signature: string; address?: string }>`
|
|
74
74
|
- Prompts the user to sign **and send** a Kit `Transaction` and returns the confirmed signature.
|
|
75
75
|
|
|
76
|
+
### Available Extension Methods
|
|
77
|
+
|
|
78
|
+
Once the `phantom.extension` object is initialized, you can access the following methods:
|
|
79
|
+
|
|
80
|
+
- `isInstalled(): boolean`
|
|
81
|
+
- Displays `true` if the phantom extension is installed, `false` if not
|
|
82
|
+
|
|
76
83
|
### Event Handling
|
|
77
84
|
|
|
78
85
|
The SDK also allows you to listen for `connect`, `disconnect`, and `accountChanged` events:
|
|
@@ -1,37 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
chains?: NetworkID[];
|
|
6
|
-
};
|
|
7
|
-
type AutoConfirmResult = {
|
|
8
|
-
enabled: boolean;
|
|
9
|
-
chains: NetworkID[];
|
|
10
|
-
};
|
|
11
|
-
type AutoConfirmSupportedChainsResult = {
|
|
12
|
-
chains: NetworkID[];
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
declare function autoConfirmEnable(params?: AutoConfirmEnableParams): Promise<AutoConfirmResult>;
|
|
16
|
-
|
|
17
|
-
declare function autoConfirmDisable(): Promise<AutoConfirmResult>;
|
|
18
|
-
|
|
19
|
-
declare function autoConfirmStatus(): Promise<AutoConfirmResult>;
|
|
20
|
-
|
|
21
|
-
declare function autoConfirmSupportedChains(): Promise<AutoConfirmSupportedChainsResult>;
|
|
22
|
-
|
|
23
|
-
type AutoConfirmPlugin = {
|
|
24
|
-
autoConfirmEnable: typeof autoConfirmEnable;
|
|
25
|
-
autoConfirmDisable: typeof autoConfirmDisable;
|
|
26
|
-
autoConfirmStatus: typeof autoConfirmStatus;
|
|
27
|
-
autoConfirmSupportedChains: typeof autoConfirmSupportedChains;
|
|
28
|
-
};
|
|
29
|
-
declare function createAutoConfirmPlugin(): Plugin<AutoConfirmPlugin>;
|
|
1
|
+
import { A as AutoConfirmPlugin } from '../index-52a9bded.js';
|
|
2
|
+
export { e as AutoConfirmEnableParams, f as AutoConfirmResult, g as AutoConfirmSupportedChainsResult, N as NetworkID, d as createAutoConfirmPlugin } from '../index-52a9bded.js';
|
|
3
|
+
import '@solana/kit';
|
|
4
|
+
import '@solana/web3.js';
|
|
30
5
|
|
|
31
6
|
declare module "../index" {
|
|
32
7
|
interface Phantom {
|
|
33
8
|
autoConfirm: AutoConfirmPlugin;
|
|
34
9
|
}
|
|
35
10
|
}
|
|
36
|
-
|
|
37
|
-
export { AutoConfirmEnableParams, AutoConfirmResult, AutoConfirmSupportedChainsResult, NetworkID, createAutoConfirmPlugin };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { E as Extension } from '../index-52a9bded.js';
|
|
2
|
+
export { b as createExtensionPlugin } from '../index-52a9bded.js';
|
|
3
|
+
import '@solana/kit';
|
|
4
|
+
import '@solana/web3.js';
|
|
5
|
+
|
|
6
|
+
declare module "../index" {
|
|
7
|
+
interface Phantom {
|
|
8
|
+
extension: Extension;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/extension/index.ts
|
|
21
|
+
var extension_exports = {};
|
|
22
|
+
__export(extension_exports, {
|
|
23
|
+
createExtensionPlugin: () => createExtensionPlugin
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(extension_exports);
|
|
26
|
+
|
|
27
|
+
// src/extension/isInstalled.ts
|
|
28
|
+
function isInstalled() {
|
|
29
|
+
try {
|
|
30
|
+
const phantom = window.phantom;
|
|
31
|
+
return !!phantom;
|
|
32
|
+
} catch (error) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// src/extension/plugin.ts
|
|
38
|
+
var extension = {
|
|
39
|
+
isInstalled
|
|
40
|
+
};
|
|
41
|
+
function createExtensionPlugin() {
|
|
42
|
+
return {
|
|
43
|
+
name: "extension",
|
|
44
|
+
create: () => extension
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
48
|
+
0 && (module.exports = {
|
|
49
|
+
createExtensionPlugin
|
|
50
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import "../chunk-GV6AIHPN.mjs";
|
|
2
|
+
|
|
3
|
+
// src/extension/isInstalled.ts
|
|
4
|
+
function isInstalled() {
|
|
5
|
+
try {
|
|
6
|
+
const phantom = window.phantom;
|
|
7
|
+
return !!phantom;
|
|
8
|
+
} catch (error) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// src/extension/plugin.ts
|
|
14
|
+
var extension = {
|
|
15
|
+
isInstalled
|
|
16
|
+
};
|
|
17
|
+
function createExtensionPlugin() {
|
|
18
|
+
return {
|
|
19
|
+
name: "extension",
|
|
20
|
+
create: () => extension
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
createExtensionPlugin
|
|
25
|
+
};
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { Transaction as Transaction$1 } from '@solana/kit';
|
|
2
|
+
import { VersionedTransaction as VersionedTransaction$1 } from '@solana/web3.js';
|
|
3
|
+
|
|
4
|
+
declare function isInstalled(): boolean;
|
|
5
|
+
|
|
6
|
+
type Extension = {
|
|
7
|
+
isInstalled: typeof isInstalled;
|
|
8
|
+
};
|
|
9
|
+
declare function createExtensionPlugin(): Plugin<Extension>;
|
|
10
|
+
|
|
11
|
+
declare function connect(): Promise<string | undefined>;
|
|
12
|
+
|
|
13
|
+
declare function disconnect(): Promise<void>;
|
|
14
|
+
|
|
15
|
+
type Transaction = {
|
|
16
|
+
message: Uint8Array;
|
|
17
|
+
recentBlockhash: string;
|
|
18
|
+
feePayer: string;
|
|
19
|
+
instructions: any[];
|
|
20
|
+
signers: string[];
|
|
21
|
+
version: number;
|
|
22
|
+
};
|
|
23
|
+
type VersionedTransaction = {
|
|
24
|
+
signatures: Uint8Array[];
|
|
25
|
+
message: {
|
|
26
|
+
deserialize: (serializedTransaction: Uint8Array) => VersionedTransaction;
|
|
27
|
+
serialize: (transaction: VersionedTransaction) => Uint8Array;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
type SendOptions = {
|
|
31
|
+
skipPreflight?: boolean;
|
|
32
|
+
preflightCommitment?: string;
|
|
33
|
+
maxRetries?: number;
|
|
34
|
+
minContextSlot?: number;
|
|
35
|
+
};
|
|
36
|
+
type PublicKey = {
|
|
37
|
+
toString: () => string;
|
|
38
|
+
toBase58: () => string;
|
|
39
|
+
};
|
|
40
|
+
type SolanaSignInData = {
|
|
41
|
+
domain?: string;
|
|
42
|
+
address?: string;
|
|
43
|
+
statement?: string;
|
|
44
|
+
uri?: string;
|
|
45
|
+
version?: string;
|
|
46
|
+
chainId?: string;
|
|
47
|
+
nonce?: string;
|
|
48
|
+
issuedAt?: string;
|
|
49
|
+
expirationTime?: string;
|
|
50
|
+
notBefore?: string;
|
|
51
|
+
requestId?: string;
|
|
52
|
+
resources?: string[];
|
|
53
|
+
};
|
|
54
|
+
type DisplayEncoding = "utf8" | "hex";
|
|
55
|
+
type PhantomEventType = "connect" | "disconnect" | "accountChanged";
|
|
56
|
+
interface PhantomSolanaProvider {
|
|
57
|
+
isPhantom: boolean;
|
|
58
|
+
publicKey: PublicKey | null;
|
|
59
|
+
isConnected: boolean;
|
|
60
|
+
connect: (opts?: {
|
|
61
|
+
onlyIfTrusted?: boolean;
|
|
62
|
+
}) => Promise<{
|
|
63
|
+
publicKey: PublicKey;
|
|
64
|
+
}>;
|
|
65
|
+
disconnect: () => Promise<void>;
|
|
66
|
+
signMessage: (message: Uint8Array, display?: DisplayEncoding) => Promise<{
|
|
67
|
+
signature: Uint8Array;
|
|
68
|
+
publicKey: PublicKey;
|
|
69
|
+
}>;
|
|
70
|
+
signIn: (signInData: SolanaSignInData) => Promise<{
|
|
71
|
+
address: PublicKey;
|
|
72
|
+
signature: Uint8Array;
|
|
73
|
+
signedMessage: Uint8Array;
|
|
74
|
+
}>;
|
|
75
|
+
signAndSendTransaction: (transaction: Transaction | VersionedTransaction, options?: SendOptions) => Promise<{
|
|
76
|
+
signature: string;
|
|
77
|
+
publicKey?: string;
|
|
78
|
+
}>;
|
|
79
|
+
signAllTransactions: (transactions: (Transaction | VersionedTransaction)[]) => Promise<(Transaction | VersionedTransaction)[]>;
|
|
80
|
+
signTransaction: (transaction: Transaction | VersionedTransaction) => Promise<Transaction | VersionedTransaction>;
|
|
81
|
+
on: (event: "connect" | "disconnect" | "accountChanged", handler: (publicKey?: PublicKey) => void) => void;
|
|
82
|
+
off: (event: "connect" | "disconnect" | "accountChanged", handler: (publicKey?: PublicKey) => void) => void;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
type ConnectCallback = (publicKey: string) => void;
|
|
86
|
+
type DisconnectCallback = () => void;
|
|
87
|
+
type AccountChangedCallback = (publicKey: string) => void;
|
|
88
|
+
type PhantomEventCallback = ConnectCallback | DisconnectCallback | AccountChangedCallback;
|
|
89
|
+
|
|
90
|
+
declare function getAccount(): Promise<string | undefined>;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Signs and sends a transaction using the Phantom provider.
|
|
94
|
+
* @param transaction The transaction to sign and send.
|
|
95
|
+
* @returns A promise that resolves with the transaction signature and optionally the public key.
|
|
96
|
+
* @throws Error if Phantom provider is not found or if the operation fails.
|
|
97
|
+
*/
|
|
98
|
+
declare function signAndSendTransaction(transaction: Transaction$1 | VersionedTransaction$1): Promise<{
|
|
99
|
+
signature: string;
|
|
100
|
+
address?: string;
|
|
101
|
+
}>;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Signs in with Solana using the Phantom provider.
|
|
105
|
+
* @param signInData The sign-in data.
|
|
106
|
+
* @returns A promise that resolves with the address, signature, and signed message.
|
|
107
|
+
* @throws Error if Phantom provider is not found or if the operation fails.
|
|
108
|
+
*/
|
|
109
|
+
declare function signIn(signInData: SolanaSignInData): Promise<{
|
|
110
|
+
address: string;
|
|
111
|
+
signature: Uint8Array;
|
|
112
|
+
signedMessage: Uint8Array;
|
|
113
|
+
}>;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Signs a message using the Phantom provider.
|
|
117
|
+
* @param message The message to sign (as a Uint8Array).
|
|
118
|
+
* @param display The display encoding for the message (optional, defaults to utf8).
|
|
119
|
+
* @returns A promise that resolves with the signature and public key.
|
|
120
|
+
* @throws Error if Phantom provider is not found or if the operation fails.
|
|
121
|
+
*/
|
|
122
|
+
declare function signMessage(message: Uint8Array, display?: DisplayEncoding): Promise<{
|
|
123
|
+
signature: Uint8Array;
|
|
124
|
+
address: string;
|
|
125
|
+
}>;
|
|
126
|
+
|
|
127
|
+
type Solana = {
|
|
128
|
+
connect: typeof connect;
|
|
129
|
+
disconnect: typeof disconnect;
|
|
130
|
+
getAccount: typeof getAccount;
|
|
131
|
+
signMessage: typeof signMessage;
|
|
132
|
+
signIn: typeof signIn;
|
|
133
|
+
signAndSendTransaction: typeof signAndSendTransaction;
|
|
134
|
+
addEventListener: (event: PhantomEventType, callback: PhantomEventCallback) => () => void;
|
|
135
|
+
removeEventListener: (event: PhantomEventType, callback: PhantomEventCallback) => void;
|
|
136
|
+
};
|
|
137
|
+
declare function createSolanaPlugin(): Plugin<Solana>;
|
|
138
|
+
|
|
139
|
+
type NetworkID = "bip122:000000000019d6689c085ae165831e93" | "bip122:000000000933ea01ad0ee984209779ba" | "solana:101" | "solana:102" | "solana:103" | "solana:localnet" | "eip155:1" | "eip155:11155111" | "eip155:137" | "eip155:80002" | "eip155:8453" | "eip155:84532" | "eip155:143" | "eip155:10143" | "eip155:41454" | "eip155:42161" | "eip155:421614" | "hypercore:mainnet" | "hypercore:testnet" | "sui:mainnet" | "sui:testnet";
|
|
140
|
+
type AutoConfirmEnableParams = {
|
|
141
|
+
chains?: NetworkID[];
|
|
142
|
+
};
|
|
143
|
+
type AutoConfirmResult = {
|
|
144
|
+
enabled: boolean;
|
|
145
|
+
chains: NetworkID[];
|
|
146
|
+
};
|
|
147
|
+
type AutoConfirmSupportedChainsResult = {
|
|
148
|
+
chains: NetworkID[];
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
declare function autoConfirmEnable(params?: AutoConfirmEnableParams): Promise<AutoConfirmResult>;
|
|
152
|
+
|
|
153
|
+
declare function autoConfirmDisable(): Promise<AutoConfirmResult>;
|
|
154
|
+
|
|
155
|
+
declare function autoConfirmStatus(): Promise<AutoConfirmResult>;
|
|
156
|
+
|
|
157
|
+
declare function autoConfirmSupportedChains(): Promise<AutoConfirmSupportedChainsResult>;
|
|
158
|
+
|
|
159
|
+
type AutoConfirmPlugin = {
|
|
160
|
+
autoConfirmEnable: typeof autoConfirmEnable;
|
|
161
|
+
autoConfirmDisable: typeof autoConfirmDisable;
|
|
162
|
+
autoConfirmStatus: typeof autoConfirmStatus;
|
|
163
|
+
autoConfirmSupportedChains: typeof autoConfirmSupportedChains;
|
|
164
|
+
};
|
|
165
|
+
declare function createAutoConfirmPlugin(): Plugin<AutoConfirmPlugin>;
|
|
166
|
+
|
|
167
|
+
type Plugin<T> = {
|
|
168
|
+
name: string;
|
|
169
|
+
create: () => T;
|
|
170
|
+
};
|
|
171
|
+
type CreatePhantomConfig = {
|
|
172
|
+
plugins?: Plugin<Solana | Extension | AutoConfirmPlugin>[];
|
|
173
|
+
};
|
|
174
|
+
interface Phantom {
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Creates a Phantom instance with the provided plugins.
|
|
178
|
+
* Each plugin extends the Phantom interface via declaration merging.
|
|
179
|
+
*/
|
|
180
|
+
declare function createPhantom({ plugins }: CreatePhantomConfig): Phantom;
|
|
181
|
+
|
|
182
|
+
export { AutoConfirmPlugin as A, CreatePhantomConfig as C, Extension as E, NetworkID as N, PhantomSolanaProvider as P, Solana as S, SolanaSignInData as a, createExtensionPlugin as b, createSolanaPlugin as c, createAutoConfirmPlugin as d, AutoConfirmEnableParams as e, AutoConfirmResult as f, AutoConfirmSupportedChainsResult as g, Plugin as h, Phantom as i, createPhantom as j };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
type CreatePhantomConfig = {
|
|
6
|
-
plugins?: Plugin<unknown>[];
|
|
7
|
-
};
|
|
8
|
-
interface Phantom {
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Creates a Phantom instance with the provided plugins.
|
|
12
|
-
* Each plugin extends the Phantom interface via declaration merging.
|
|
13
|
-
*/
|
|
14
|
-
declare function createPhantom({ plugins }: CreatePhantomConfig): Phantom;
|
|
15
|
-
|
|
16
|
-
export { CreatePhantomConfig, Phantom, Plugin, createPhantom };
|
|
1
|
+
export { C as CreatePhantomConfig, i as Phantom, h as Plugin, j as createPhantom } from './index-52a9bded.js';
|
|
2
|
+
import '@solana/kit';
|
|
3
|
+
import '@solana/web3.js';
|
package/dist/solana/index.d.ts
CHANGED
|
@@ -1,139 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
declare function connect(): Promise<string | undefined>;
|
|
6
|
-
|
|
7
|
-
declare function disconnect(): Promise<void>;
|
|
8
|
-
|
|
9
|
-
type Transaction = {
|
|
10
|
-
message: Uint8Array;
|
|
11
|
-
recentBlockhash: string;
|
|
12
|
-
feePayer: string;
|
|
13
|
-
instructions: any[];
|
|
14
|
-
signers: string[];
|
|
15
|
-
version: number;
|
|
16
|
-
};
|
|
17
|
-
type VersionedTransaction = {
|
|
18
|
-
signatures: Uint8Array[];
|
|
19
|
-
message: {
|
|
20
|
-
deserialize: (serializedTransaction: Uint8Array) => VersionedTransaction;
|
|
21
|
-
serialize: (transaction: VersionedTransaction) => Uint8Array;
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
type SendOptions = {
|
|
25
|
-
skipPreflight?: boolean;
|
|
26
|
-
preflightCommitment?: string;
|
|
27
|
-
maxRetries?: number;
|
|
28
|
-
minContextSlot?: number;
|
|
29
|
-
};
|
|
30
|
-
type PublicKey = {
|
|
31
|
-
toString: () => string;
|
|
32
|
-
toBase58: () => string;
|
|
33
|
-
};
|
|
34
|
-
type SolanaSignInData = {
|
|
35
|
-
domain?: string;
|
|
36
|
-
address?: string;
|
|
37
|
-
statement?: string;
|
|
38
|
-
uri?: string;
|
|
39
|
-
version?: string;
|
|
40
|
-
chainId?: string;
|
|
41
|
-
nonce?: string;
|
|
42
|
-
issuedAt?: string;
|
|
43
|
-
expirationTime?: string;
|
|
44
|
-
notBefore?: string;
|
|
45
|
-
requestId?: string;
|
|
46
|
-
resources?: string[];
|
|
47
|
-
};
|
|
48
|
-
type DisplayEncoding = "utf8" | "hex";
|
|
49
|
-
type PhantomEventType = "connect" | "disconnect" | "accountChanged";
|
|
50
|
-
interface PhantomSolanaProvider {
|
|
51
|
-
isPhantom: boolean;
|
|
52
|
-
publicKey: PublicKey | null;
|
|
53
|
-
isConnected: boolean;
|
|
54
|
-
connect: (opts?: {
|
|
55
|
-
onlyIfTrusted?: boolean;
|
|
56
|
-
}) => Promise<{
|
|
57
|
-
publicKey: PublicKey;
|
|
58
|
-
}>;
|
|
59
|
-
disconnect: () => Promise<void>;
|
|
60
|
-
signMessage: (message: Uint8Array, display?: DisplayEncoding) => Promise<{
|
|
61
|
-
signature: Uint8Array;
|
|
62
|
-
publicKey: PublicKey;
|
|
63
|
-
}>;
|
|
64
|
-
signIn: (signInData: SolanaSignInData) => Promise<{
|
|
65
|
-
address: PublicKey;
|
|
66
|
-
signature: Uint8Array;
|
|
67
|
-
signedMessage: Uint8Array;
|
|
68
|
-
}>;
|
|
69
|
-
signAndSendTransaction: (transaction: Transaction | VersionedTransaction, options?: SendOptions) => Promise<{
|
|
70
|
-
signature: string;
|
|
71
|
-
publicKey?: string;
|
|
72
|
-
}>;
|
|
73
|
-
signAllTransactions: (transactions: (Transaction | VersionedTransaction)[]) => Promise<(Transaction | VersionedTransaction)[]>;
|
|
74
|
-
signTransaction: (transaction: Transaction | VersionedTransaction) => Promise<Transaction | VersionedTransaction>;
|
|
75
|
-
on: (event: "connect" | "disconnect" | "accountChanged", handler: (publicKey?: PublicKey) => void) => void;
|
|
76
|
-
off: (event: "connect" | "disconnect" | "accountChanged", handler: (publicKey?: PublicKey) => void) => void;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
type ConnectCallback = (publicKey: string) => void;
|
|
80
|
-
type DisconnectCallback = () => void;
|
|
81
|
-
type AccountChangedCallback = (publicKey: string) => void;
|
|
82
|
-
type PhantomEventCallback = ConnectCallback | DisconnectCallback | AccountChangedCallback;
|
|
83
|
-
|
|
84
|
-
declare function getAccount(): Promise<string | undefined>;
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Signs and sends a transaction using the Phantom provider.
|
|
88
|
-
* @param transaction The transaction to sign and send.
|
|
89
|
-
* @returns A promise that resolves with the transaction signature and optionally the public key.
|
|
90
|
-
* @throws Error if Phantom provider is not found or if the operation fails.
|
|
91
|
-
*/
|
|
92
|
-
declare function signAndSendTransaction(transaction: Transaction$1 | VersionedTransaction$1): Promise<{
|
|
93
|
-
signature: string;
|
|
94
|
-
address?: string;
|
|
95
|
-
}>;
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Signs in with Solana using the Phantom provider.
|
|
99
|
-
* @param signInData The sign-in data.
|
|
100
|
-
* @returns A promise that resolves with the address, signature, and signed message.
|
|
101
|
-
* @throws Error if Phantom provider is not found or if the operation fails.
|
|
102
|
-
*/
|
|
103
|
-
declare function signIn(signInData: SolanaSignInData): Promise<{
|
|
104
|
-
address: string;
|
|
105
|
-
signature: Uint8Array;
|
|
106
|
-
signedMessage: Uint8Array;
|
|
107
|
-
}>;
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Signs a message using the Phantom provider.
|
|
111
|
-
* @param message The message to sign (as a Uint8Array).
|
|
112
|
-
* @param display The display encoding for the message (optional, defaults to utf8).
|
|
113
|
-
* @returns A promise that resolves with the signature and public key.
|
|
114
|
-
* @throws Error if Phantom provider is not found or if the operation fails.
|
|
115
|
-
*/
|
|
116
|
-
declare function signMessage(message: Uint8Array, display?: DisplayEncoding): Promise<{
|
|
117
|
-
signature: Uint8Array;
|
|
118
|
-
address: string;
|
|
119
|
-
}>;
|
|
120
|
-
|
|
121
|
-
type Solana = {
|
|
122
|
-
connect: typeof connect;
|
|
123
|
-
disconnect: typeof disconnect;
|
|
124
|
-
getAccount: typeof getAccount;
|
|
125
|
-
signMessage: typeof signMessage;
|
|
126
|
-
signIn: typeof signIn;
|
|
127
|
-
signAndSendTransaction: typeof signAndSendTransaction;
|
|
128
|
-
addEventListener: (event: PhantomEventType, callback: PhantomEventCallback) => () => void;
|
|
129
|
-
removeEventListener: (event: PhantomEventType, callback: PhantomEventCallback) => void;
|
|
130
|
-
};
|
|
131
|
-
declare function createSolanaPlugin(): Plugin<Solana>;
|
|
1
|
+
import { S as Solana } from '../index-52a9bded.js';
|
|
2
|
+
export { P as PhantomSolanaProvider, a as SolanaSignInData, c as createSolanaPlugin } from '../index-52a9bded.js';
|
|
3
|
+
import '@solana/kit';
|
|
4
|
+
import '@solana/web3.js';
|
|
132
5
|
|
|
133
6
|
declare module "../index" {
|
|
134
7
|
interface Phantom {
|
|
135
8
|
solana: Solana;
|
|
136
9
|
}
|
|
137
10
|
}
|
|
138
|
-
|
|
139
|
-
export { PhantomSolanaProvider, SolanaSignInData, createSolanaPlugin };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phantom/browser-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -15,6 +15,11 @@
|
|
|
15
15
|
"require": "./dist/solana/index.js",
|
|
16
16
|
"types": "./dist/solana/index.d.ts"
|
|
17
17
|
},
|
|
18
|
+
"./extension": {
|
|
19
|
+
"import": "./dist/extension/index.mjs",
|
|
20
|
+
"require": "./dist/extension/index.js",
|
|
21
|
+
"types": "./dist/extension/index.d.ts"
|
|
22
|
+
},
|
|
18
23
|
"./auto-confirm": {
|
|
19
24
|
"import": "./dist/auto-confirm/index.mjs",
|
|
20
25
|
"require": "./dist/auto-confirm/index.js",
|
|
@@ -28,9 +33,9 @@
|
|
|
28
33
|
"scripts": {
|
|
29
34
|
"?pack-release": "When https://github.com/changesets/changesets/issues/432 has a solution we can remove this trick",
|
|
30
35
|
"pack-release": "rimraf ./_release && yarn pack && mkdir ./_release && tar zxvf ./package.tgz --directory ./_release && rm ./package.tgz",
|
|
31
|
-
"build": "rimraf ./dist && tsup src/index.ts src/solana/index.ts src/auto-confirm/index.ts --format cjs,esm --dts",
|
|
32
|
-
"build:watch": "rimraf ./dist && tsup src/index.ts src/solana/index.ts src/auto-confirm/index.ts --format cjs,esm --dts --watch",
|
|
33
|
-
"dev": "rimraf ./dist && tsup src/index.ts src/solana/index.ts src/auto-confirm/index.ts --format cjs,esm --dts --watch",
|
|
36
|
+
"build": "rimraf ./dist && tsup src/index.ts src/solana/index.ts src/extension/index.ts src/auto-confirm/index.ts --format cjs,esm --dts",
|
|
37
|
+
"build:watch": "rimraf ./dist && tsup src/index.ts src/solana/index.ts src/extension/index.ts src/auto-confirm/index.ts --format cjs,esm --dts --watch",
|
|
38
|
+
"dev": "rimraf ./dist && tsup src/index.ts src/solana/index.ts src/extension/index.ts src/auto-confirm/index.ts --format cjs,esm --dts --watch",
|
|
34
39
|
"lint": "tsc --noEmit && eslint --cache . --ext .ts,.tsx",
|
|
35
40
|
"test": "jest"
|
|
36
41
|
},
|