Skip to content

Commit d482c95

Browse files
committed
fix: Pass network to requestPermissions to ensure wallet connects to Shadownet
The wallet was connecting to mainnet instead of shadownet because requestPermissions() was called without a network parameter. This fix explicitly passes the network config (including rpcUrl for shadownet) to requestPermissions(), ensuring the wallet connects to the correct network.
1 parent a9c562d commit d482c95

2 files changed

Lines changed: 29 additions & 7 deletions

File tree

MIGRATION-GHOSTNET-TO-SHADOWNET.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Reference: https://teztnets.com/shadownet-about
2323
| TzKT Explorer | ✅ Ready | `shadownet.tzkt.io` |
2424
| Shadownet Faucet | ✅ Ready | `faucet.shadownet.teztnets.com` |
2525
| SmartPy RPC | ❓ Unknown | May not support shadownet |
26-
| Beacon Wallet SDK | ⚠️ Custom | Needs `NetworkType.CUSTOM` |
26+
| Beacon Wallet SDK | ✅ Ready | Upgraded to 4.7.0 with native `NetworkType.SHADOWNET` |
2727
| Better Call Dev | ❓ Unknown | May not support shadownet |
2828

2929
---
@@ -80,9 +80,10 @@ REACT_APP_RPC_NETWORK_SHADOWNET=https://rpc.shadownet.teztnets.com
8080

8181
## Testing Checklist
8282

83-
- [ ] Get tez from shadownet faucet
84-
- [ ] Test wallet connection with Temple/Kukai
85-
- [ ] Test token creation
83+
- [x] Get tez from shadownet faucet
84+
- [x] Test wallet connection with Temple/Kukai (Kukai works with Beacon SDK 4.7.0)
85+
- [x] Fix: Wallet was connecting to mainnet instead of shadownet (now passes network to `requestPermissions`)
86+
- [ ] Test token creation (on correct network)
8687
- [ ] Test DAO creation flow
8788
- [ ] Test staking
8889
- [ ] Test proposal creation

src/services/beacon/utils.ts

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,19 @@ export const getTezosNetwork = (): Network => {
6060
export const createWallet = (network: Network) => {
6161
const networkType = getNetworkTypeByEnvNetwork(network)
6262

63+
// For Shadownet, include the RPC URL so wallets know exactly which network to connect to
64+
const networkConfig =
65+
network === "shadownet"
66+
? {
67+
type: networkType,
68+
rpcUrl: rpcNodes.shadownet
69+
}
70+
: { type: networkType }
71+
6372
return new BeaconWallet({
6473
name: "Homebase",
6574
iconUrl: "https://tezostaquito.io/img/favicon.png",
66-
network: { type: networkType },
75+
network: networkConfig,
6776
walletConnectOptions: {
6877
projectId: "1641355e825aeaa926e843dd38b04f6f", // Project ID can be customised
6978
relayUrl: "wss://relay.walletconnect.com" // WC2 relayUrl can be customised
@@ -98,8 +107,20 @@ export const connectWithBeacon = async (
98107
wallet: BeaconWallet
99108
}> => {
100109
const wallet = createWallet(envNetwork)
101-
102-
await wallet.requestPermissions()
110+
const networkType = getNetworkTypeByEnvNetwork(envNetwork)
111+
112+
// Explicitly pass network to requestPermissions to ensure wallet connects to correct network
113+
const permissionRequest =
114+
envNetwork === "shadownet"
115+
? {
116+
network: {
117+
type: networkType,
118+
rpcUrl: rpcNodes.shadownet
119+
}
120+
}
121+
: { network: { type: networkType } }
122+
123+
await wallet.requestPermissions(permissionRequest)
103124

104125
const accounts: any[] = JSON.parse(localStorage.getItem("beacon:accounts") as string)
105126

0 commit comments

Comments
 (0)