Skip to content

Commit fd9ed28

Browse files
committed
fix address localStorage
1 parent 327ad9d commit fd9ed28

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

components/Body/index.tsx

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,12 @@ function Body() {
102102
} = useSafeInject();
103103

104104
const [provider, setProvider] = useState<ethers.providers.JsonRpcProvider>();
105-
const [showAddress, setShowAddress] = useState(addressFromURL ?? ""); // gets displayed in input. ENS name remains as it is
106-
const [address, setAddress] = useState(addressFromURL ?? ""); // internal resolved address
105+
const [showAddress, setShowAddress] = useState(
106+
addressFromURL ?? localStorage.getItem("showAddress") ?? ""
107+
); // gets displayed in input. ENS name remains as it is
108+
const [address, setAddress] = useState(
109+
addressFromURL ?? localStorage.getItem("showAddress") ?? ""
110+
); // internal resolved address
107111
const [isAddressValid, setIsAddressValid] = useState(true);
108112
const [uri, setUri] = useState("");
109113
const [networkId, setNetworkId] = useState(networkIdViaURL);
@@ -128,9 +132,8 @@ function Body() {
128132
);
129133
const [iframeKey, setIframeKey] = useState(0); // hacky way to reload iframe when key changes
130134

131-
const storedTenderlyForkId = localStorage.getItem("tenderlyForkId");
132135
const [tenderlyForkId, setTenderlyForkId] = useState(
133-
storedTenderlyForkId ?? ""
136+
localStorage.getItem("tenderlyForkId") ?? ""
134137
);
135138
const [sendTxnData, setSendTxnData] = useState<TxnDataType[]>([]);
136139

@@ -245,6 +248,7 @@ function Body() {
245248
if (onlyIfActiveSessions) {
246249
const sessions = _web3wallet.getActiveSessions();
247250
const sessionsArray = Object.values(sessions);
251+
console.log({ sessions });
248252
if (sessionsArray.length > 0) {
249253
const _address =
250254
sessionsArray[0].namespaces["eip155"].accounts[0].split(":")[2];
@@ -507,12 +511,21 @@ function Body() {
507511

508512
// Approve Call Request
509513
if (web3wallet && topic) {
514+
// await web3wallet.respondSessionRequest({
515+
// topic,
516+
// response: {
517+
// jsonrpc: "2.0",
518+
// id: res.id,
519+
// result: res.result,
520+
// },
521+
// });
522+
510523
await web3wallet.respondSessionRequest({
511524
topic,
512525
response: {
513526
jsonrpc: "2.0",
514-
id: res.id,
515-
result: res.result,
527+
id: id,
528+
error: { code: 0, message: "Method not supported by Impersonator" },
516529
},
517530
});
518531
}
@@ -601,6 +614,10 @@ function Body() {
601614
console.log("ACTION", "killSession");
602615

603616
if (web3wallet && web3WalletSession) {
617+
setWeb3WalletSession(undefined);
618+
setUri("");
619+
setIsConnected(false);
620+
604621
try {
605622
await web3wallet.disconnectSession({
606623
topic: web3WalletSession.topic,
@@ -609,9 +626,6 @@ function Body() {
609626
} catch (e) {
610627
console.error("killSession", e);
611628
}
612-
setWeb3WalletSession(undefined);
613-
setUri("");
614-
setIsConnected(false);
615629
}
616630
};
617631

0 commit comments

Comments
 (0)