Skip to content

Commit

Permalink
[config] Remove duplicate code
Browse files Browse the repository at this point in the history
  • Loading branch information
gregnazario committed Oct 11, 2023
1 parent e2889a1 commit bea410e
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/api/aptos_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,15 @@ export class AptosConfig {
switch (apiType) {
case AptosApiType.FULLNODE:
if (this.fullnode !== undefined) return this.fullnode;
if (this.network === Network.CUSTOM && this.fullnode === undefined)
throw new Error("Please provide a custom full node url");
if (this.network === Network.CUSTOM) throw new Error("Please provide a custom full node url");
return NetworkToNodeAPI[this.network];
case AptosApiType.FAUCET:
if (this.faucet !== undefined) return this.faucet;
if (this.network === Network.CUSTOM && this.faucet === undefined)
throw new Error("Please provide a custom faucet url");
if (this.network === Network.CUSTOM) throw new Error("Please provide a custom faucet url");
return NetworkToFaucetAPI[this.network];
case AptosApiType.INDEXER:
if (this.indexer !== undefined) return this.indexer;
if (this.network === Network.CUSTOM && this.indexer === undefined)
throw new Error("Please provide a custom indexer url");
if (this.network === Network.CUSTOM) throw new Error("Please provide a custom indexer url");
return NetworkToIndexerAPI[this.network];
default:
throw Error(`apiType ${apiType} is not supported`);
Expand Down

0 comments on commit bea410e

Please sign in to comment.