Skip to content

Commit

Permalink
fix: switch chain init _blocto
Browse files Browse the repository at this point in the history
  • Loading branch information
akira02 committed Dec 6, 2023
1 parent 43228a6 commit 8970168
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion packages/blocto-sdk/src/providers/ethereum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -756,11 +756,16 @@ export default class EthereumProvider
this.networkVersion = `${newChainId}`;
this.chainId = `0x${newChainId.toString(16)}`;
this.rpc = switchableNetwork[newChainId].rpc_url;
this._blocto = {
...this._blocto,
blockchainName: '',
networkType: '',
};
if (!oldAccount) {
this.eventListeners?.chainChanged.forEach((listener) =>
listener(this.chainId)
);
this.#getBloctoProperties();
await this.#getBloctoProperties();
return null;
}
// Go login flow when switching to a different blocto server
Expand All @@ -784,6 +789,11 @@ export default class EthereumProvider
this.networkVersion = `${oldChainId}`;
this.chainId = `0x${oldChainId.toString(16)}`;
this.rpc = switchableNetwork[oldChainId].rpc_url;
this._blocto = {
...this._blocto,
blockchainName: '',
networkType: '',
};
this.#getBloctoProperties();
throw error;
});
Expand Down Expand Up @@ -843,6 +853,12 @@ export default class EthereumProvider
this.networkVersion = `${oldChainId}`;
this.chainId = `0x${oldChainId.toString(16)}`;
this.rpc = switchableNetwork[oldChainId].rpc_url;
this._blocto = {
...this._blocto,
blockchainName: '',
networkType: '',
};
this.#getBloctoProperties();
reject(ethErrors.provider.userRejectedRequest());
}
}
Expand Down

0 comments on commit 8970168

Please sign in to comment.