Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi instance usage #115

Open
DaniSchenk opened this issue Aug 2, 2024 · 1 comment
Open

Multi instance usage #115

DaniSchenk opened this issue Aug 2, 2024 · 1 comment

Comments

@DaniSchenk
Copy link

I try to use a multi Kiln sdk instance approach that looks similar to this:

class KilnService {
  private clientMainnet: Kiln;
  private clientTestnet: Kiln;

  constructor() {
    this.clientMainnet = new Kiln({
      apiToken: "xxx",
      testnet: false,
      baseUrl: "https://api.kiln.fi",
    });

    this.clientTestnet = new Kiln({
      apiToken: "xxx",
      testnet: true,
    });
  }
}

Once I do requests like await this.clientMainnet.accounts.getAll() I see that requests are made to api.testnet.kiln.fi even if mainnet sdk instance was used. Going further, I changed the order of initialization in the constructor (testnet first, mainnet second) all requests - no matter what instance was used - were made to api.kiln.fi.

Can you replicate this behavior? Are both instances sharing the same axios instance, maybe? If that's the root cause, then every Kiln sdk class instance should get its axios instance IMO. IMO, this is more intuitive, and instances must not be recreated before usage.

@nooxx
Copy link
Collaborator

nooxx commented Sep 12, 2024

Hey thanks for reporting this issue! There is indeed one axios instance.
We'll fix asap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants