Skip to content

Commit

Permalink
LegacySDK({apiKey?})
Browse files Browse the repository at this point in the history
  • Loading branch information
Velenir committed Feb 6, 2024
1 parent 65f9a9b commit 134fdd5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/legacy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ type TxResponse = Web3UnpromiEvent | ContractTransaction;
type LegacyOptions = {
chainId?: number;
apiURL?: string;
apiKey?: string;
web3Provider?: Web3;
ethersDeps?: EthersProviderDeps; // need to be a provider with signer for approve requests
account?: Address;
Expand All @@ -71,6 +72,7 @@ export class ParaSwap {
constructor({
chainId = 1,
apiURL = API_URL,
apiKey,
web3Provider,
ethersDeps,
account,
Expand All @@ -84,17 +86,17 @@ export class ParaSwap {
this.account = account;

const fetcher = axios
? constructAxiosFetcher(axios)
? constructAxiosFetcher(axios, { apiKey })
: fetch
? constructFetchFetcher(fetch)
? constructFetchFetcher(fetch, { apiKey })
: null;

assert(fetcher, 'at least one fetcher is needed');
this.fetcher = fetcher;

if (!web3Provider && !ethersDeps) {
this.sdk = constructPartialSDK(
{ fetcher, apiURL, chainId },
{ fetcher, apiURL, apiKey, chainId },
constructGetBalances,
constructGetTokens,
constructGetSpender,
Expand Down

0 comments on commit 134fdd5

Please sign in to comment.