Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/data/dto/common.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,13 @@ describe('dto/common helpers', () => {
});

describe('getMarketDataProviderUrl', () => {
it('handles CsprTrade', () => {
it('handles CsprTrade with contract package hash', () => {
expect(getMarketDataProviderUrl('CsprTrade', null, null, 'cph-123')).toBe(
'https://cspr.trade/token-details/cph-123',
);
});

it('falls back to cspr.trade homepage without package hash', () => {
expect(getMarketDataProviderUrl('CsprTrade')).toBe('https://cspr.trade/');
});

Expand Down
5 changes: 4 additions & 1 deletion src/data/dto/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,13 @@ export function getMarketDataProviderUrl(
marketDataProvider: Maybe<SupportedMarketDataProviders>,
coingeckoId?: string | null,
latestVersionContractHash?: string | null,
contractPackageHash?: string | null,
) {
switch (marketDataProvider) {
case 'CsprTrade':
return 'https://cspr.trade/'; // TODO link to token page
return contractPackageHash
? `https://cspr.trade/token-details/${contractPackageHash}`
: 'https://cspr.trade/';
case 'CoinGecko':
return coingeckoId ? `https://www.coingecko.com/en/coins/${coingeckoId}` : null;
case 'FriendlyMarket':
Expand Down
1 change: 1 addition & 0 deletions src/data/dto/deploys/Cep18DeployDto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export class Cep18DeployDto extends DeployDto implements ICep18Deploy {
this.marketDataProvider,
data?.contract_package?.coingecko_id,
data?.contract_package?.latest_version_contract_hash,
data?.contract_package?.contract_package_hash,
);
}

Expand Down
1 change: 1 addition & 0 deletions src/data/dto/deploys/Cep18transferDeployDto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export class Cep18TransferDeployDto implements ICep18Deploy {
this.marketDataProvider,
data?.contract_package?.coingecko_id,
data?.contract_package?.latest_version_contract_hash,
data?.contract_package?.contract_package_hash,
);
}

Expand Down
1 change: 1 addition & 0 deletions src/data/dto/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export class TokenDto implements ITokenWithFiatBalance {
this.marketDataProvider,
apiToken?.coingecko_id,
apiToken?.latest_version_contract_hash,
this.contractPackageHash,
);
}

Expand Down
Loading