From d4e641ba85c785112f18b094e8aa72c1b97e3186 Mon Sep 17 00:00:00 2001 From: bucurdavid Date: Mon, 11 Nov 2024 17:04:59 +0200 Subject: [PATCH] refactor: remove redundant static param --- src/datanft.ts | 39 +++++++-------------------------------- tests/datanft.test.ts | 2 +- 2 files changed, 8 insertions(+), 33 deletions(-) diff --git a/src/datanft.ts b/src/datanft.ts index 7ecfb08..fb6440b 100644 --- a/src/datanft.ts +++ b/src/datanft.ts @@ -70,7 +70,6 @@ export class DataNft implements DataNftType { }[] = []; static networkConfiguration: Config; - static apiConfiguration: string; static env: string; /** @@ -108,34 +107,10 @@ export class DataNft implements DataNftType { } this.env = env; this.networkConfiguration = networkConfiguration[env as EnvironmentsEnum]; - this.apiConfiguration = apiConfiguration[env as EnvironmentsEnum]; - - console.log( - 'SDK debug: setNetworkConfig this.apiConfiguration B4 =', - this.apiConfiguration - ); - console.log( - 'SDK debug: setNetworkConfig this.networkConfiguration B4 =', - this.networkConfiguration - ); if (useSpecificApiEndpoint && useSpecificApiEndpoint.trim() !== '') { - this.apiConfiguration = useSpecificApiEndpoint.trim(); this.networkConfiguration.networkProvider = useSpecificApiEndpoint.trim(); } - - console.log( - 'SDK debug: setNetworkConfig useSpecificApiEndpoint A8 =', - useSpecificApiEndpoint - ); - console.log( - 'SDK debug: setNetworkConfig this.apiConfiguration A8 =', - this.apiConfiguration - ); - console.log( - 'SDK debug: setNetworkConfig this.networkConfiguration A8 =', - this.networkConfiguration - ); } /** @@ -156,7 +131,9 @@ export class DataNft implements DataNftType { token.nonce ); - const response = await fetch(`${this.apiConfiguration}/nfts/${identifier}`); + const response = await fetch( + `${this.networkConfiguration.networkProvider}/nfts/${identifier}` + ); checkStatus(response); @@ -199,10 +176,8 @@ export class DataNft implements DataNftType { return []; } - console.log('SDK debug: createManyFromApi api =', this.apiConfiguration); - const fetchUrl = `${ - this.apiConfiguration + this.networkConfiguration.networkProvider }/nfts?identifiers=${identifiers.join(',')}&withSupply=true&size=${ identifiers.length }`; @@ -304,7 +279,7 @@ export class DataNft implements DataNftType { dataNftTokenIdentifier[this.env as EnvironmentsEnum]; const res = await fetch( - `${this.apiConfiguration}/accounts/${address}/nfts?size=10000&collections=${identifiersMap}&withSupply=true` + `${this.networkConfiguration.networkProvider}/accounts/${address}/nfts?size=10000&collections=${identifiersMap}&withSupply=true` ); checkStatus(res); @@ -325,7 +300,7 @@ export class DataNft implements DataNftType { const identifier = createTokenIdentifier(this.tokenIdentifier, this.nonce); const response = await fetch( - `${DataNft.apiConfiguration}/nfts/${identifier}/accounts` + `${DataNft.networkConfiguration.networkProvider}/nfts/${identifier}/accounts` ); checkStatus(response); @@ -711,7 +686,7 @@ export class DataNft implements DataNftType { } private static ensureNetworkConfigSet() { - if (!this.env || !this.apiConfiguration) { + if (!this.env || !this.networkConfiguration) { throw new ErrNetworkConfig(); } } diff --git a/tests/datanft.test.ts b/tests/datanft.test.ts index fc4226b..f9babd1 100644 --- a/tests/datanft.test.ts +++ b/tests/datanft.test.ts @@ -86,7 +86,7 @@ describe('Data NFT test', () => { for (const item of dataNfts) { expect(item).toBeInstanceOf(Object as unknown as DataNft); } - }); + }, 10000); test('#create many data NFTs different token identifiers', async () => { DataNft.setNetworkConfig('devnet');