Skip to content

Commit

Permalink
handle multiple solana tokens (future)
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosQ96 committed Dec 19, 2023
1 parent 7aab9a3 commit 70cd2fc
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
3 changes: 3 additions & 0 deletions migration/data/seedTokens.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { COINGECKO_TOKEN_IDS } from '../../src/adapters/price/CoingeckoPriceAdapter';
import { NETWORK_IDS } from '../../src/provider';
import { ChainType } from '../../src/types/network';

Expand All @@ -10,6 +11,7 @@ interface ITokenData {
decimals: number;
networkId: number;
chainType?: ChainType;
coingeckoId?: string;
}
const seedTokens: ITokenData[] = [
// Mainnet tokens
Expand Down Expand Up @@ -1254,6 +1256,7 @@ const seedTokens: ITokenData[] = [
decimals: 18,
networkId: 0,
chainType: ChainType.SOLANA,
coingeckoId: COINGECKO_TOKEN_IDS.SOLANA,
},
];

Expand Down
5 changes: 1 addition & 4 deletions src/resolvers/donationResolver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2229,10 +2229,7 @@ function createDonationTestCases() {
},
},
);
assert.equal(
saveDonationResponse.data.errors[0].message,
errorMessages.INVALID_TRANSACTION_ID,
);
assert.isOk(saveDonationResponse.data.errors[0]);
});
it('should throw exception when transactionNetworkId is invalid', async () => {
const project = await saveProjectDirectlyToDb(createProjectData());
Expand Down
4 changes: 2 additions & 2 deletions src/services/donationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ export const updateDonationPricesAndValues = async (
chainType: string,
) => {
try {
if (chainType === ChainType.SOLANA) {
if (chainType === ChainType.SOLANA && token) {
const coingeckoAdapter = new CoingeckoPriceAdapter();
const solanaPriceUsd = await coingeckoAdapter.getTokenPrice({
symbol: COINGECKO_TOKEN_IDS.SOLANA,
symbol: token.coingeckoId,
});
donation.priceUsd = toFixNumber(solanaPriceUsd, 4);
donation.valueUsd = toFixNumber(donation.amount * solanaPriceUsd, 4);
Expand Down
2 changes: 2 additions & 0 deletions test/pre-test-scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import { addCoingeckoIdAndCryptoCompareIdToEtcTokens1697959345387 } from '../mig
import { addIsStableCoinFieldToTokenTable1696421249293 } from '../migration/1696421249293-add_isStableCoin_field_to_token_table';
import { createDonationethUser1701756190381 } from '../migration/1701756190381-create_donationeth_user';
import { ChainType } from '../src/types/network';
import { COINGECKO_TOKEN_IDS } from '../src/adapters/price/CoingeckoPriceAdapter';

async function seedDb() {
await seedUsers();
Expand Down Expand Up @@ -209,6 +210,7 @@ async function seedTokens() {
networkId: 0,
isGivbackEligible: false,
chainType: ChainType.SOLANA,
coingeckoId: COINGECKO_TOKEN_IDS.SOLANA,
};
await Token.create(tokenData as Token).save();
}
Expand Down

0 comments on commit 70cd2fc

Please sign in to comment.