Skip to content

Commit 1afc908

Browse files
committed
fix: update initIExecSDKs to work without wallet connection
1 parent 2046f43 commit 1afc908

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

src/externals/iexecSdkClient.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,30 @@ export function cleanIExecSDKs() {
1414
readonlyIExec = null;
1515
}
1616

17-
export async function initIExecSDKs({ connector }: { connector?: Connector }) {
17+
export async function initIExecSDKs({
18+
connector,
19+
chainId,
20+
}: {
21+
connector?: Connector;
22+
chainId?: number;
23+
}) {
24+
let provider = chainId as unknown as Eip1193Provider;
1825
if (!connector || !connector.getProvider) {
1926
cleanIExecSDKs();
20-
return;
27+
} else {
28+
provider = (await connector.getProvider()) as Eip1193Provider;
2129
}
22-
23-
const provider = (await connector.getProvider()) as Eip1193Provider;
2430
if (!provider) {
2531
cleanIExecSDKs();
2632
return;
2733
}
34+
2835
// Initialize
2936
const config = new IExecConfig(
3037
{ ethProvider: provider },
3138
{ allowExperimentalNetworks: true }
3239
);
40+
console.log('config', provider);
3341
iExec = new IExec(config);
3442

3543
IEXEC_CLIENT_RESOLVES.forEach((resolve) => resolve(iExec!));

src/hooks/ChainSyncManger.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,8 @@ export function ChainSyncManager() {
4242
if (accountChain?.id && chainId !== accountChain?.id) {
4343
setChainId(accountChain?.id);
4444
}
45-
if (accountStatus === 'connected') {
46-
initIExecSDKs({ connector: accountConnector });
47-
return;
48-
}
4945
cleanIExecSDKs();
46+
initIExecSDKs({ connector: accountConnector, chainId });
5047
}, [
5148
accountAddress,
5249
accountIsConnected,

0 commit comments

Comments
 (0)