Skip to content

Commit 5ba2563

Browse files
authored
Coins decimals type (#10945)
* number * check decimals before transform * avnu address padding
1 parent 00a73cd commit 5ba2563

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

coins/src/adapters/bridges/anvu.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { lowercaseAddress } from "../../utils/processCoin";
12
import { fetch } from "../utils";
23
import { Token } from "./index";
34

@@ -10,10 +11,9 @@ export default async function bridge() {
1011

1112
bridge.map((token) => {
1213
const { address, symbol, decimals, extensions: { coingeckoId} } = token;
13-
if (!coingeckoId) return
1414
tokens.push({
15-
from: `starknet:${address}`,
16-
to: `coingecko:${coingeckoId}`,
15+
from: lowercaseAddress(`starknet:${address}`),
16+
to: `coingecko#${coingeckoId}`,
1717
symbol,
1818
decimals,
1919
});

coins/src/adapters/bridges/aptosFa.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default async function bridge(): Promise<Token[]> {
1111
if (faAddress && coinGeckoId)
1212
tokens.push({
1313
from: `aptos:${faAddress}`,
14-
to: `coingecko:${coinGeckoId}`,
14+
to: `coingecko#${coinGeckoId}`,
1515
decimals,
1616
symbol,
1717
});
@@ -25,7 +25,7 @@ export default async function bridge(): Promise<Token[]> {
2525
if (coinGeckoId && tokenAddress)
2626
tokens.push({
2727
from: `aptos:${tokenAddress}`,
28-
to: `coingecko:${coinGeckoId}`,
28+
to: `coingecko#${coinGeckoId}`,
2929
decimals,
3030
symbol,
3131
});

coins/src/adapters/bridges/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ async function _storeTokensOfBridge(bridge: Bridge, i: number) {
209209
const finalPK = toAddressToRecord[craftToPK(token.to)];
210210
if (finalPK === undefined) return;
211211

212-
let decimals: number, symbol: string;
212+
let decimals: any, symbol: string;
213213
if ("getAllInfo" in token) {
214214
try {
215215
const newToken = await token.getAllInfo();
@@ -224,8 +224,10 @@ async function _storeTokensOfBridge(bridge: Bridge, i: number) {
224224
symbol = token.symbol;
225225
}
226226

227+
if (isNaN(decimals) || decimals == '' || decimals == null) return;
227228
if (i && !decimals) return;
228229
if (!symbol) return;
230+
decimals = Number(decimals)
229231

230232
writes.push({
231233
PK: `asset#${token.from}`,

coins/src/scripts/coingecko.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,13 +279,13 @@ async function getAndStoreCoins(coins: Coin[], rejected: Coin[]) {
279279
decimals = symbolAndDecimals.decimals;
280280
symbol = symbolAndDecimals.symbol;
281281
}
282-
if (decimals == undefined) return;
282+
if (isNaN(decimals) || decimals == '' || decimals == null) return;
283283

284284
const item = {
285285
PK: normalizedPK,
286286
SK: 0,
287287
created,
288-
decimals,
288+
decimals: Number(decimals),
289289
symbol,
290290
redirect: cgPK(coin.id),
291291
confidence: 0.99,

0 commit comments

Comments
 (0)