@phantom/browser-sdk 1.0.0-beta.20 → 1.0.0-beta.21
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 +22 -25
- package/dist/index.js +5 -4
- package/dist/index.mjs +5 -4
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -544,7 +544,7 @@ const result = await sdk.ethereum.sendTransaction({
|
|
|
544
544
|
|
|
545
545
|
#### switchChain(chainId)
|
|
546
546
|
|
|
547
|
-
Switch to a different Ethereum chain.
|
|
547
|
+
Switch to a different Ethereum chain. Accepts a chain ID as a number or a hex string value.
|
|
548
548
|
|
|
549
549
|
```typescript
|
|
550
550
|
await sdk.ethereum.switchChain(1); // Ethereum mainnet
|
|
@@ -552,6 +552,21 @@ await sdk.ethereum.switchChain(137); // Polygon
|
|
|
552
552
|
await sdk.ethereum.switchChain(42161); // Arbitrum One
|
|
553
553
|
```
|
|
554
554
|
|
|
555
|
+
**Supported EVM Networks:**
|
|
556
|
+
|
|
557
|
+
| Network | Chain ID | Usage |
|
|
558
|
+
|---------|----------|-------|
|
|
559
|
+
| Ethereum Mainnet | `1` | `switchChain(1)` |
|
|
560
|
+
| Ethereum Sepolia | `11155111` | `switchChain(11155111)` |
|
|
561
|
+
| Polygon Mainnet | `137` | `switchChain(137)` |
|
|
562
|
+
| Polygon Amoy | `80002` | `switchChain(80002)` |
|
|
563
|
+
| Base Mainnet | `8453` | `switchChain(8453)` |
|
|
564
|
+
| Base Sepolia | `84532` | `switchChain(84532)` |
|
|
565
|
+
| Arbitrum One | `42161` | `switchChain(42161)` |
|
|
566
|
+
| Arbitrum Sepolia | `421614` | `switchChain(421614)` |
|
|
567
|
+
| Monad Mainnet | `143` | `switchChain(143)` |
|
|
568
|
+
| Monad Testnet | `10143` | `switchChain(10143)` |
|
|
569
|
+
|
|
555
570
|
#### getChainId()
|
|
556
571
|
|
|
557
572
|
Get the current chain ID.
|
|
@@ -744,33 +759,15 @@ console.log("Supported chains:", supportedChains.chains);
|
|
|
744
759
|
|
|
745
760
|
#### Available NetworkId Values
|
|
746
761
|
|
|
762
|
+
For a complete list of supported networks including Solana, Ethereum, Polygon, Base, Arbitrum, Monad, and more, see the [Network Support section in the main README](../../README.md#network-support).
|
|
763
|
+
|
|
747
764
|
```typescript
|
|
748
765
|
import { NetworkId } from "@phantom/browser-sdk";
|
|
749
766
|
|
|
750
|
-
//
|
|
751
|
-
|
|
752
|
-
NetworkId.
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
// Ethereum networks
|
|
756
|
-
NetworkId.ETHEREUM_MAINNET; // "eip155:1"
|
|
757
|
-
NetworkId.ETHEREUM_SEPOLIA; // "eip155:11155111"
|
|
758
|
-
|
|
759
|
-
// Polygon networks
|
|
760
|
-
NetworkId.POLYGON_MAINNET; // "eip155:137"
|
|
761
|
-
NetworkId.POLYGON_AMOY; // "eip155:80002"
|
|
762
|
-
|
|
763
|
-
// Arbitrum networks
|
|
764
|
-
NetworkId.ARBITRUM_ONE; // "eip155:42161"
|
|
765
|
-
NetworkId.ARBITRUM_SEPOLIA; // "eip155:421614"
|
|
766
|
-
|
|
767
|
-
// Optimism networks
|
|
768
|
-
NetworkId.OPTIMISM_MAINNET; // "eip155:10"
|
|
769
|
-
NetworkId.OPTIMISM_GOERLI; // "eip155:420"
|
|
770
|
-
|
|
771
|
-
// Base networks
|
|
772
|
-
NetworkId.BASE_MAINNET; // "eip155:8453"
|
|
773
|
-
NetworkId.BASE_SEPOLIA; // "eip155:84532"
|
|
767
|
+
// Example: Use NetworkId for auto-confirm
|
|
768
|
+
await sdk.enableAutoConfirm({
|
|
769
|
+
chains: [NetworkId.SOLANA_MAINNET, NetworkId.ETHEREUM_MAINNET],
|
|
770
|
+
});
|
|
774
771
|
```
|
|
775
772
|
|
|
776
773
|
**Important Notes:**
|
package/dist/index.js
CHANGED
|
@@ -319,8 +319,9 @@ var InjectedEthereumChain = class {
|
|
|
319
319
|
return await this.phantom.ethereum.sendTransaction(transaction);
|
|
320
320
|
}
|
|
321
321
|
async switchChain(chainId) {
|
|
322
|
-
|
|
323
|
-
this.
|
|
322
|
+
const hexChainId = typeof chainId === "string" ? chainId.toLowerCase().startsWith("0x") ? chainId : `0x${parseInt(chainId, 10).toString(16)}` : `0x${chainId.toString(16)}`;
|
|
323
|
+
await this.phantom.ethereum.switchChain(hexChainId);
|
|
324
|
+
this._chainId = hexChainId;
|
|
324
325
|
this.eventEmitter.emit("chainChanged", this._chainId);
|
|
325
326
|
}
|
|
326
327
|
async getChainId() {
|
|
@@ -1200,7 +1201,7 @@ var BrowserAuthProvider = class {
|
|
|
1200
1201
|
// OAuth session management - defaults to allow refresh unless explicitly clearing after logout
|
|
1201
1202
|
clear_previous_session: (phantomOptions.clearPreviousSession ?? false).toString(),
|
|
1202
1203
|
allow_refresh: (phantomOptions.allowRefresh ?? true).toString(),
|
|
1203
|
-
sdk_version: "1.0.0-beta.
|
|
1204
|
+
sdk_version: "1.0.0-beta.21",
|
|
1204
1205
|
sdk_type: "browser",
|
|
1205
1206
|
platform: detectBrowser().name
|
|
1206
1207
|
});
|
|
@@ -1459,7 +1460,7 @@ var EmbeddedProvider = class extends import_embedded_provider_core.EmbeddedProvi
|
|
|
1459
1460
|
// Full user agent for more detailed info
|
|
1460
1461
|
[import_constants2.ANALYTICS_HEADERS.APP_ID]: config.appId,
|
|
1461
1462
|
[import_constants2.ANALYTICS_HEADERS.WALLET_TYPE]: config.embeddedWalletType,
|
|
1462
|
-
[import_constants2.ANALYTICS_HEADERS.SDK_VERSION]: "1.0.0-beta.
|
|
1463
|
+
[import_constants2.ANALYTICS_HEADERS.SDK_VERSION]: "1.0.0-beta.21"
|
|
1463
1464
|
// Replaced at build time
|
|
1464
1465
|
}
|
|
1465
1466
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -282,8 +282,9 @@ var InjectedEthereumChain = class {
|
|
|
282
282
|
return await this.phantom.ethereum.sendTransaction(transaction);
|
|
283
283
|
}
|
|
284
284
|
async switchChain(chainId) {
|
|
285
|
-
|
|
286
|
-
this.
|
|
285
|
+
const hexChainId = typeof chainId === "string" ? chainId.toLowerCase().startsWith("0x") ? chainId : `0x${parseInt(chainId, 10).toString(16)}` : `0x${chainId.toString(16)}`;
|
|
286
|
+
await this.phantom.ethereum.switchChain(hexChainId);
|
|
287
|
+
this._chainId = hexChainId;
|
|
287
288
|
this.eventEmitter.emit("chainChanged", this._chainId);
|
|
288
289
|
}
|
|
289
290
|
async getChainId() {
|
|
@@ -1163,7 +1164,7 @@ var BrowserAuthProvider = class {
|
|
|
1163
1164
|
// OAuth session management - defaults to allow refresh unless explicitly clearing after logout
|
|
1164
1165
|
clear_previous_session: (phantomOptions.clearPreviousSession ?? false).toString(),
|
|
1165
1166
|
allow_refresh: (phantomOptions.allowRefresh ?? true).toString(),
|
|
1166
|
-
sdk_version: "1.0.0-beta.
|
|
1167
|
+
sdk_version: "1.0.0-beta.21",
|
|
1167
1168
|
sdk_type: "browser",
|
|
1168
1169
|
platform: detectBrowser().name
|
|
1169
1170
|
});
|
|
@@ -1422,7 +1423,7 @@ var EmbeddedProvider = class extends CoreEmbeddedProvider {
|
|
|
1422
1423
|
// Full user agent for more detailed info
|
|
1423
1424
|
[ANALYTICS_HEADERS.APP_ID]: config.appId,
|
|
1424
1425
|
[ANALYTICS_HEADERS.WALLET_TYPE]: config.embeddedWalletType,
|
|
1425
|
-
[ANALYTICS_HEADERS.SDK_VERSION]: "1.0.0-beta.
|
|
1426
|
+
[ANALYTICS_HEADERS.SDK_VERSION]: "1.0.0-beta.21"
|
|
1426
1427
|
// Replaced at build time
|
|
1427
1428
|
}
|
|
1428
1429
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phantom/browser-sdk",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.21",
|
|
4
4
|
"description": "Browser SDK for Phantom Wallet",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -28,15 +28,15 @@
|
|
|
28
28
|
"prettier": "prettier --write \"src/**/*.{ts,tsx}\""
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@phantom/base64url": "^1.0.0-beta.
|
|
31
|
+
"@phantom/base64url": "^1.0.0-beta.9",
|
|
32
32
|
"@phantom/browser-injected-sdk": "^1.0.0-beta.6",
|
|
33
|
-
"@phantom/chain-interfaces": "^1.0.0-beta.
|
|
34
|
-
"@phantom/client": "^1.0.0-beta.
|
|
35
|
-
"@phantom/constants": "^1.0.0-beta.
|
|
36
|
-
"@phantom/embedded-provider-core": "^1.0.0-beta.
|
|
33
|
+
"@phantom/chain-interfaces": "^1.0.0-beta.9",
|
|
34
|
+
"@phantom/client": "^1.0.0-beta.21",
|
|
35
|
+
"@phantom/constants": "^1.0.0-beta.9",
|
|
36
|
+
"@phantom/embedded-provider-core": "^1.0.0-beta.21",
|
|
37
37
|
"@phantom/indexed-db-stamper": "^1.0.0-beta.2",
|
|
38
|
-
"@phantom/parsers": "^1.0.0-beta.
|
|
39
|
-
"@phantom/sdk-types": "^1.0.0-beta.
|
|
38
|
+
"@phantom/parsers": "^1.0.0-beta.9",
|
|
39
|
+
"@phantom/sdk-types": "^1.0.0-beta.9",
|
|
40
40
|
"axios": "^1.10.0",
|
|
41
41
|
"bs58": "^6.0.0",
|
|
42
42
|
"buffer": "^6.0.3",
|