Skip to content

Commit

Permalink
fix(core): the reconnect method was causing an infinite loop (#808)
Browse files Browse the repository at this point in the history
  • Loading branch information
moldy530 committed Aug 13, 2024
1 parent 3d5b9c5 commit 0d09472
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
11 changes: 7 additions & 4 deletions account-kit/core/src/actions/reconnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ export async function reconnect(config: AlchemyAccountsConfig) {
const signerConfig = clientStore.getState().config;
const accountConfigs = clientStore.getState().accountConfigs;

const signer = createSigner(signerConfig);
const signer = clientStore.getState().signer ?? createSigner(signerConfig);
if (!clientStore.getState().signer) {
clientStore.setState({
signer,
});
}

const chain = getChain(config);
clientStore.setState({
signer,
});

const unsubConnected = signer.on("connected", async () => {
if (accountConfigs[chain.id]?.["LightAccount"]) {
Expand Down
2 changes: 1 addition & 1 deletion account-kit/infra/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const AlchemyChainSchema = z.custom<Chain>((chain) => {
const chain_ = ChainSchema.parse(chain);

return chain_.rpcUrls.alchemy != null;
}, "chain must include an alchemy rpc url. See `createAlchemyChain` or use the `AlchemyChainMap` exported from `@aa-sdk/core`");
}, "chain must include an alchemy rpc url. See `createAlchemyChain` or import a chain from `@account-kit/infra`.");

export const AlchemyProviderConfigSchema = ConnectionConfigSchema.and(
z.object({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ describe("Light Account Client Tests", () => {
"[
{
\\"code\\": \\"custom\\",
\\"message\\": \\"chain must include an alchemy rpc url. See \`createAlchemyChain\` or use the \`AlchemyChainMap\` exported from \`@aa-sdk/core\`\\",
\\"message\\": \\"chain must include an alchemy rpc url. See \`createAlchemyChain\` or import a chain from \`@account-kit/infra\`.\\",
\\"fatal\\": true,
\\"path\\": [
\\"chain\\"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ describe("MultiOwnerLightAccount Client Tests", () => {
"[
{
\\"code\\": \\"custom\\",
\\"message\\": \\"chain must include an alchemy rpc url. See \`createAlchemyChain\` or use the \`AlchemyChainMap\` exported from \`@aa-sdk/core\`\\",
\\"message\\": \\"chain must include an alchemy rpc url. See \`createAlchemyChain\` or import a chain from \`@account-kit/infra\`.\\",
\\"fatal\\": true,
\\"path\\": [
\\"chain\\"
Expand Down

0 comments on commit 0d09472

Please sign in to comment.