Skip to content

Commit

Permalink
fix: Alchemy support on RSK
Browse files Browse the repository at this point in the history
  • Loading branch information
michael1011 committed Feb 13, 2025
1 parent 7a6b6c6 commit ef23265
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
9 changes: 6 additions & 3 deletions lib/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,10 @@ type TokenConfig = {
};

type EthProviderServiceConfig = {
network: string;
apiKey: string;
network?: string;
apiKey?: string;

endpoint?: string;
};

type ContractsConfig = {
Expand All @@ -112,14 +114,15 @@ type RskConfig = {
networkName?: string;
providerEndpoint: string;

alchemy: EthProviderServiceConfig;

contracts: ContractsConfig[];

tokens: TokenConfig[];
};

type EthereumConfig = RskConfig & {
infura: EthProviderServiceConfig;
alchemy: EthProviderServiceConfig;
};

type ApiConfig = {
Expand Down
2 changes: 1 addition & 1 deletion lib/chain/ElementsWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class ElementsWrapper
);
}

this.logger.info(`Using 0-conf check ${this.zeroConfCheck.name}`);
this.logger.info(`Using 0-conf check: ${this.zeroConfCheck.name}`);
}

public serviceName = () => 'ElementsWrapper';
Expand Down
21 changes: 13 additions & 8 deletions lib/wallet/ethereum/InjectedProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ class InjectedProvider implements Provider {
name: EthProviderService,
providerConfig: EthProviderServiceConfig,
) => {
if (providerConfig === undefined || providerConfig.apiKey === undefined) {
this.logDisabledProvider(name, 'no api key was set');
return;
}

if (providerConfig.network === undefined) {
this.logDisabledProvider(name, 'no network was specified');
if (
providerConfig === undefined ||
(providerConfig.endpoint === undefined &&
(providerConfig.network === undefined ||
providerConfig.apiKey === undefined))
) {
this.logDisabledProvider(name, 'not configured');
return;
}

Expand All @@ -151,7 +151,12 @@ class InjectedProvider implements Provider {
case EthProviderService.Alchemy:
this.providers.set(
name,
new AlchemyProvider(providerConfig.network, providerConfig.apiKey),
providerConfig.endpoint
? new JsonRpcProvider(providerConfig.endpoint)
: new AlchemyProvider(
providerConfig.network,
providerConfig.apiKey,
),
);
break;

Expand Down

0 comments on commit ef23265

Please sign in to comment.