Skip to content
This repository was archived by the owner on Aug 30, 2022. It is now read-only.

Commit 264eed4

Browse files
jarrodwattsjnsdls
andauthored
Fix magic link connector (#92)
* Fix magic link connector * fix magic connector properly? * update local storage key to fix broken state Co-authored-by: Jonas Daniels <jonas.daniels@outlook.com>
1 parent d2cd2fe commit 264eed4

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ yalc.lock
55
temp/
66
.swc/
77
*.log
8-
.DS_Store
8+
.DS_Store
9+
# jns shenanigans
10+
old_src/

src/Provider.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,10 @@ export const ThirdwebProvider = <
250250
return _supporrtedChains.reduce((prev, curr) => {
251251
prev[curr.id] =
252252
curr.id in chainRpc
253-
? chainRpc[curr.id as keyof ChainRpc<TSupportedChain>] ||
254-
curr.rpcUrls[0]
253+
? (getProviderForNetwork(
254+
chainRpc[curr.id as keyof ChainRpc<TSupportedChain>] ||
255+
curr.rpcUrls[0],
256+
) as string)
255257
: curr.rpcUrls[0];
256258
return prev;
257259
}, {} as Record<number, string>);

src/connectors/magic.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ export interface MagicConnectorArguments
1616

1717
const __IS_SERVER__ = typeof window === "undefined";
1818

19+
const LOCAL_STORAGE_KEY = "--magic-link:configuration";
20+
1921
export class MagicConnector extends Connector {
2022
readonly id = "magic";
2123
readonly name = "Magic";
@@ -30,7 +32,7 @@ export class MagicConnector extends Connector {
3032
return undefined;
3133
}
3234

33-
const config = window.localStorage.getItem("-magic-link:configuration");
35+
const config = window.localStorage.getItem(LOCAL_STORAGE_KEY);
3436
if (config) {
3537
this.configuration = JSON.parse(config);
3638
}
@@ -175,12 +177,12 @@ export class MagicConnector extends Connector {
175177
if (configuration) {
176178
this.configuration = configuration;
177179
window.localStorage.setItem(
178-
"-magic-link:configuration",
180+
LOCAL_STORAGE_KEY,
179181
JSON.stringify(configuration),
180182
);
181183
} else {
182184
this.configuration = undefined;
183-
window.localStorage.removeItem("-magic-link:configuration");
185+
window.localStorage.removeItem(LOCAL_STORAGE_KEY);
184186
}
185187
}
186188
}

0 commit comments

Comments
 (0)