Closed akornato closed 1 year ago
This is a known issue, in that if there is a saved state of mainnet
in the users session, eg saved to cookie or in localstorage, the network=
value in the client provider will be ignored.
I will be pushing an update this week that will change the behavior of the network value, such that folks can either force the setting of network via that value, or have it be set as the "default" value, which if there is a different value for the user session, it will be ignored.
To test and make sure this is the case, can you clear all application data (localStorage, cookies, etc), and make sure testnet
is the value, and then determine that it's either testnet or mainnet on the server?
Also, if you can share a reproduction or repo for your project, that would help.
Please update your dependencies to their latest versions and let me know if you run into any issues!
@aulneau with your fix #159 (thanks for the PR to my repo!) the lib is updating the local storage & cookie when signing out/in, but it's still putting Mainnet address in them even if there's both network="testnet" supplied to ClientProvider and Hiro Wallet signs in to Testnet. My repo is https://github.com/akornato/stacks-dashboard deployed at https://stacks-dashboard.vercel.app
@akornato I just tried out your project and found it to behave as I expect:
_app.tsx
testnet
to mainnet
in _app.tsx
If you do not pass enableNetworkSwitching
to the config, the value saved to localStorage or cookie will be ignored, and the only value that matters is what is passed to the Config provider.
Does this help? If you have other questions please let me know!
@aulneau indeed useAccount
and useCurrentStxAddress
are now returning Testnet address on the server correctly, that's great! However the dehydratedState
I'm accessing in getServerSideProps
still has Mainnet address. I need the Testnet address there to be able to fetch correct data for Testnet address on the server.
Is there a solution to accessing the testnet
address from the dehydratedState
when using getServerSideProps
?
micro-stacks.store
local storage value always has Mainnet address, even if there's bothnetwork="testnet"
supplied toClientProvider
and Hiro Wallet signs in to Testnet. Same forClientProvider
onPersistState
dehydratedState
, so it seems impossible to SSR correctly on Testnet becauseuseAccount
stxAddress
is always the Mainnet one (even thoughuseNetwork
isMainnet
is correctlyfalse
).