@phantom/browser-sdk 0.3.8 → 1.0.0-beta.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.
- package/README.md +457 -430
- package/dist/index.d.ts +58 -30
- package/dist/index.js +351 -235
- package/dist/index.mjs +355 -226
- package/package.json +10 -9
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import { EmbeddedProviderConfig, AuthOptions, ConnectResult,
|
|
1
|
+
import { EmbeddedProviderConfig, AuthOptions, ConnectResult, WalletAddress, EmbeddedProviderEvent, EventCallback } from '@phantom/embedded-provider-core';
|
|
2
2
|
export { AuthOptions, ConnectResult, SignAndSendTransactionParams, SignMessageParams, SignMessageResult, SignedTransaction, WalletAddress } from '@phantom/embedded-provider-core';
|
|
3
|
+
import { ISolanaChain, IEthereumChain } from '@phantom/chains';
|
|
4
|
+
export { EthTransactionRequest, IEthereumChain, ISolanaChain } from '@phantom/chains';
|
|
3
5
|
import { AddressType } from '@phantom/client';
|
|
4
6
|
export { AddressType } from '@phantom/client';
|
|
7
|
+
import { AutoConfirmEnableParams, AutoConfirmResult, AutoConfirmSupportedChainsResult } from '@phantom/browser-injected-sdk/auto-confirm';
|
|
8
|
+
export { AutoConfirmEnableParams, AutoConfirmResult, AutoConfirmSupportedChainsResult } from '@phantom/browser-injected-sdk/auto-confirm';
|
|
5
9
|
export { NetworkId } from '@phantom/constants';
|
|
6
10
|
|
|
7
11
|
declare enum DebugLevel {
|
|
@@ -65,10 +69,10 @@ interface BrowserSDKConfig extends Partial<EmbeddedProviderConfig> {
|
|
|
65
69
|
interface Provider {
|
|
66
70
|
connect(authOptions?: AuthOptions): Promise<ConnectResult>;
|
|
67
71
|
disconnect(): Promise<void>;
|
|
68
|
-
signMessage(params: SignMessageParams): Promise<SignMessageResult>;
|
|
69
|
-
signAndSendTransaction(params: SignAndSendTransactionParams): Promise<SignedTransaction>;
|
|
70
72
|
getAddresses(): WalletAddress[];
|
|
71
73
|
isConnected(): boolean;
|
|
74
|
+
solana: ISolanaChain;
|
|
75
|
+
ethereum: IEthereumChain;
|
|
72
76
|
}
|
|
73
77
|
|
|
74
78
|
interface ProviderPreference {
|
|
@@ -79,58 +83,62 @@ interface SwitchProviderOptions {
|
|
|
79
83
|
embeddedWalletType?: "app-wallet" | "user-wallet" | (string & Record<never, never>);
|
|
80
84
|
}
|
|
81
85
|
|
|
86
|
+
/**
|
|
87
|
+
* Browser SDK with chain-specific API
|
|
88
|
+
*
|
|
89
|
+
* Usage:
|
|
90
|
+
* ```typescript
|
|
91
|
+
* const sdk = new BrowserSDK({ providerType: 'embedded', appId: 'your-app-id' });
|
|
92
|
+
* await sdk.connect();
|
|
93
|
+
*
|
|
94
|
+
* // Chain-specific operations
|
|
95
|
+
* await sdk.solana.signMessage(message);
|
|
96
|
+
* await sdk.ethereum.signPersonalMessage(message, address);
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
82
99
|
declare class BrowserSDK {
|
|
83
100
|
private providerManager;
|
|
84
101
|
constructor(config: BrowserSDKConfig);
|
|
85
102
|
/**
|
|
86
|
-
*
|
|
103
|
+
* Access Solana chain operations
|
|
87
104
|
*/
|
|
88
|
-
|
|
89
|
-
providerType?: "injected" | "embedded" | (string & Record<never, never>);
|
|
90
|
-
embeddedWalletType?: "app-wallet" | "user-wallet" | (string & Record<never, never>);
|
|
91
|
-
authOptions?: AuthOptions;
|
|
92
|
-
}): Promise<ConnectResult>;
|
|
105
|
+
get solana(): ISolanaChain;
|
|
93
106
|
/**
|
|
94
|
-
*
|
|
107
|
+
* Access Ethereum chain operations
|
|
95
108
|
*/
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Get current provider information
|
|
99
|
-
*/
|
|
100
|
-
getCurrentProviderInfo(): ProviderPreference | null;
|
|
109
|
+
get ethereum(): IEthereumChain;
|
|
101
110
|
/**
|
|
102
|
-
*
|
|
111
|
+
* Connect to the wallet
|
|
103
112
|
*/
|
|
104
|
-
|
|
113
|
+
connect(options?: AuthOptions): Promise<ConnectResult>;
|
|
105
114
|
/**
|
|
106
115
|
* Disconnect from the wallet
|
|
107
116
|
*/
|
|
108
117
|
disconnect(): Promise<void>;
|
|
109
118
|
/**
|
|
110
|
-
*
|
|
111
|
-
* @param message - Message string to sign
|
|
112
|
-
* @param networkId - Network identifier
|
|
113
|
-
* @returns Signature string
|
|
119
|
+
* Switch between provider types (injected vs embedded)
|
|
114
120
|
*/
|
|
115
|
-
|
|
121
|
+
switchProvider(type: "injected" | "embedded", options?: SwitchProviderOptions): Promise<void>;
|
|
116
122
|
/**
|
|
117
|
-
*
|
|
118
|
-
* @param params - Transaction parameters with native transaction object
|
|
119
|
-
* @returns Transaction result
|
|
123
|
+
* Check if the SDK is connected to a wallet
|
|
120
124
|
*/
|
|
121
|
-
|
|
125
|
+
isConnected(): boolean;
|
|
122
126
|
/**
|
|
123
|
-
* Get wallet addresses
|
|
127
|
+
* Get all connected wallet addresses
|
|
124
128
|
*/
|
|
125
129
|
getAddresses(): WalletAddress[];
|
|
126
130
|
/**
|
|
127
|
-
*
|
|
131
|
+
* Get information about the current provider
|
|
128
132
|
*/
|
|
129
|
-
|
|
133
|
+
getCurrentProviderInfo(): ProviderPreference | null;
|
|
130
134
|
/**
|
|
131
|
-
* Get the
|
|
135
|
+
* Get the wallet ID (for embedded wallets)
|
|
132
136
|
*/
|
|
133
137
|
getWalletId(): string | null;
|
|
138
|
+
/**
|
|
139
|
+
* Check if Phantom extension is installed
|
|
140
|
+
*/
|
|
141
|
+
static isPhantomInstalled(): boolean;
|
|
134
142
|
/**
|
|
135
143
|
* Add event listener for provider events (connect, connect_start, connect_error, disconnect, error)
|
|
136
144
|
* Works with both embedded and injected providers
|
|
@@ -175,6 +183,26 @@ declare class BrowserSDK {
|
|
|
175
183
|
level?: DebugLevel;
|
|
176
184
|
callback?: DebugCallback;
|
|
177
185
|
}): void;
|
|
186
|
+
/**
|
|
187
|
+
* Enable auto-confirm for transactions
|
|
188
|
+
* Only available for injected providers
|
|
189
|
+
*/
|
|
190
|
+
enableAutoConfirm(params: AutoConfirmEnableParams): Promise<AutoConfirmResult>;
|
|
191
|
+
/**
|
|
192
|
+
* Disable auto-confirm for transactions
|
|
193
|
+
* Only available for injected providers
|
|
194
|
+
*/
|
|
195
|
+
disableAutoConfirm(): Promise<void>;
|
|
196
|
+
/**
|
|
197
|
+
* Get current auto-confirm status
|
|
198
|
+
* Only available for injected providers
|
|
199
|
+
*/
|
|
200
|
+
getAutoConfirmStatus(): Promise<AutoConfirmResult>;
|
|
201
|
+
/**
|
|
202
|
+
* Get supported chains for auto-confirm
|
|
203
|
+
* Only available for injected providers
|
|
204
|
+
*/
|
|
205
|
+
getSupportedAutoConfirmChains(): Promise<AutoConfirmSupportedChainsResult>;
|
|
178
206
|
}
|
|
179
207
|
|
|
180
208
|
/**
|