@phantom/browser-sdk 1.0.0 → 1.0.3
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 +9 -15
- package/dist/index.d.ts +3 -3
- package/dist/index.js +574 -703
- package/dist/index.mjs +554 -683
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -149,8 +149,8 @@ const result = await sdk.solana.signAndSendTransaction(transaction);
|
|
|
149
149
|
await sdk.solana.switchNetwork("devnet");
|
|
150
150
|
|
|
151
151
|
// Utilities
|
|
152
|
-
const publicKey =
|
|
153
|
-
const isConnected = sdk.solana.isConnected
|
|
152
|
+
const publicKey = sdk.solana.publicKey;
|
|
153
|
+
const isConnected = sdk.solana.isConnected;
|
|
154
154
|
```
|
|
155
155
|
|
|
156
156
|
### Ethereum Chain (`sdk.ethereum`)
|
|
@@ -462,21 +462,12 @@ await sdk.solana.switchNetwork("mainnet");
|
|
|
462
462
|
await sdk.solana.switchNetwork("devnet");
|
|
463
463
|
```
|
|
464
464
|
|
|
465
|
-
####
|
|
466
|
-
|
|
467
|
-
Get the current Solana public key.
|
|
468
|
-
|
|
469
|
-
```typescript
|
|
470
|
-
const publicKey = await sdk.solana.getPublicKey();
|
|
471
|
-
// Returns: string | null
|
|
472
|
-
```
|
|
473
|
-
|
|
474
|
-
#### isConnected()
|
|
465
|
+
#### isConnected
|
|
475
466
|
|
|
476
467
|
Check if connected to Solana wallet.
|
|
477
468
|
|
|
478
469
|
```typescript
|
|
479
|
-
const connected = sdk.solana.isConnected
|
|
470
|
+
const connected = sdk.solana.isConnected;
|
|
480
471
|
// Returns: boolean
|
|
481
472
|
```
|
|
482
473
|
|
|
@@ -738,6 +729,7 @@ const sdk = new BrowserSDK({
|
|
|
738
729
|
sdk.on("connect_start", (data: ConnectStartEventData) => {
|
|
739
730
|
console.log("Connection starting:", data.source); // "auto-connect" | "manual-connect"
|
|
740
731
|
console.log("Auth options:", data.authOptions?.provider); // "google" | "apple" | etc.
|
|
732
|
+
console.log("Wallet ID:", data.walletId); // only for embedded providers
|
|
741
733
|
});
|
|
742
734
|
|
|
743
735
|
// 2. connect - Fired when connection succeeds (includes full ConnectResult)
|
|
@@ -1030,7 +1022,8 @@ const connection = new Connection("https://api.mainnet-beta.solana.com");
|
|
|
1030
1022
|
const { blockhash } = await connection.getLatestBlockhash();
|
|
1031
1023
|
|
|
1032
1024
|
// Create transfer instruction
|
|
1033
|
-
const fromAddress =
|
|
1025
|
+
const fromAddress = sdk.solana.publicKey;
|
|
1026
|
+
if (!fromAddress) throw new Error("Not connected");
|
|
1034
1027
|
const transferInstruction = SystemProgram.transfer({
|
|
1035
1028
|
fromPubkey: new PublicKey(fromAddress),
|
|
1036
1029
|
toPubkey: new PublicKey(toAddress),
|
|
@@ -1082,7 +1075,8 @@ await sdk.connect({ provider: "injected" });
|
|
|
1082
1075
|
const rpc = createSolanaRpc("https://api.mainnet-beta.solana.com");
|
|
1083
1076
|
const { value: latestBlockhash } = await rpc.getLatestBlockhash().send();
|
|
1084
1077
|
|
|
1085
|
-
const userPublicKey =
|
|
1078
|
+
const userPublicKey = sdk.solana.publicKey;
|
|
1079
|
+
if (!userPublicKey) throw new Error("Not connected");
|
|
1086
1080
|
const transactionMessage = pipe(
|
|
1087
1081
|
createTransactionMessage({ version: 0 }),
|
|
1088
1082
|
tx => setTransactionMessageFeePayer(address(userPublicKey), tx),
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { AddressType } from '@phantom/client';
|
|
|
6
6
|
export { AddressType } from '@phantom/client';
|
|
7
7
|
import { AutoConfirmEnableParams, AutoConfirmResult, AutoConfirmSupportedChainsResult } from '@phantom/browser-injected-sdk/auto-confirm';
|
|
8
8
|
export { AutoConfirmEnableParams, AutoConfirmResult, AutoConfirmSupportedChainsResult } from '@phantom/browser-injected-sdk/auto-confirm';
|
|
9
|
-
export { NetworkId } from '@phantom/constants';
|
|
9
|
+
export { NetworkId, PHANTOM_ICON } from '@phantom/constants';
|
|
10
10
|
|
|
11
11
|
declare enum DebugLevel {
|
|
12
12
|
ERROR = 0,
|
|
@@ -102,7 +102,7 @@ interface InjectedWalletInfo {
|
|
|
102
102
|
providers?: WalletProviders;
|
|
103
103
|
/** Reverse DNS identifier from EIP-6963 (for potential future matching with Wallet Standard) */
|
|
104
104
|
rdns?: string;
|
|
105
|
-
discovery?: "standard" | "eip6963" | "phantom";
|
|
105
|
+
discovery?: "standard" | "eip6963" | "phantom" | "custom";
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
interface DebugConfig {
|
|
@@ -280,7 +280,7 @@ declare function isMobileDevice(): boolean;
|
|
|
280
280
|
* @param ref Optional referrer parameter
|
|
281
281
|
* @returns Phantom mobile app deeplink URL
|
|
282
282
|
*/
|
|
283
|
-
declare function getDeeplinkToPhantom(ref?: string): string;
|
|
283
|
+
declare function getDeeplinkToPhantom(ref?: string, currentHref?: string): string;
|
|
284
284
|
|
|
285
285
|
/**
|
|
286
286
|
* Wait for Phantom extension to be available with retry logic
|