Skip to content

Commit

Permalink
Merge pull request #210 from bnb-chain/server/stargateAPI
Browse files Browse the repository at this point in the history
feat: Stargate endpoint ID
  • Loading branch information
Halibao-Lala authored Dec 23, 2024
2 parents 5b38145 + fe8b484 commit 16d752a
Show file tree
Hide file tree
Showing 3 changed files with 150 additions and 3 deletions.
132 changes: 132 additions & 0 deletions apps/canonical-bridge-server/src/common/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,135 @@ export const JOB_KEY = {
CORN_TOKEN_PREFIX: 'corn:token:',
CORN_PRICE_PREFIX: 'corn:price:',
};

export const STARGATE_CHAIN_INFO = [
{
chainId: 1,
chainName: 'Ethereum',
endpointID: 30101,
},
{
chainId: 10,
chainName: 'Optimism',
endpointID: 30110,
},
{
chainId: 14,
chainName: 'Flare',
endpointID: 30295,
},
{
chainId: 56,
chainName: 'BSC',
endpointID: 30102,
},
{
chainId: 97,
chainName: 'BSC Testnet',
network: 'testnet',
endpointID: 40102,
},
{
chainId: 137,
chainName: 'Polygon',
endpointID: 30109,
},
{
chainId: 1088,
chainName: 'Metis',
endpointID: 30151,
},
{
chainId: 1116,
chainName: 'coredao',
endpointID: 30153,
},
{
chainId: 1329,
chainName: 'Sei',
endpointID: 30280,
},
{
chainId: 1625,
chainName: 'Gravity',
endpointID: 30294,
},
{
chainId: 2222,
chainName: 'Kava',
endpointID: 30177,
},
{
chainId: 5000,
chainName: 'Mantle',
endpointID: 30181,
},
{
chainId: 8217,
chainName: 'Klaytn',
endpointID: 30150,
},
{
chainId: 8453,
chainName: 'Base',
endpointID: 30184,
},
{
chainId: 8822,
chainName: 'IOTA',
endpointID: 30284,
},
{
chainId: 42161,
chainName: 'Arbitrum',
endpointID: 30110,
},
{
chainId: 43114,
chainName: 'Avalanche',
endpointID: 30106,
},
{
chainId: 59144,
chainName: 'Linea',
endpointID: 30183,
},
{
chainId: 167000,
chainName: 'Taiko',
endpointID: 30290,
},
{
chainId: 421614,
chainName: 'Arbitrum Sepolia',
network: 'testnet',
endpointID: 40231,
},
{
chainId: 11155420,
chainName: 'OP Sepolia Testnet',
network: 'testnet',
endpointID: 40232,
},
{
chainId: 534352,
chainName: 'Scroll',
endpointID: 30214,
},
{
chainId: 11155111,
chainName: 'Sepolia',
network: 'testnet',
endpointID: 40161,
},
{
chainId: 1313161554,
chainName: 'Aurora',
endpointID: 30211,
},
{
chainId: 1380012617,
chainName: 'rarible',
endpointID: 30235,
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,12 @@ export interface IStargateBridgeTokenInfo {
decimals: number;
symbol: string;
};
lpToken: {
lpToken?: {
address: `0x${string}`;
decimals: number;
symbol: string;
};
farm: {
farm?: {
stargateStaking: {
address: `0x${string}`;
rewardTokens: [
Expand Down
17 changes: 16 additions & 1 deletion apps/canonical-bridge-server/src/shared/web3/web3.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
MESON_ENDPOINT,
LLAMA_COINS_ENDPOINT,
TOKEN_REQUEST_LIMIT,
STARGATE_CHAIN_INFO,
} from '@/common/constants';
import { values } from 'lodash';

Expand Down Expand Up @@ -86,7 +87,21 @@ export class Web3Service {
const { data } = await this.httpService.axiosRef.get<IStargateTokenList>(
`${STARGATE_ENDPOINT}`,
);
return data;
const processedTokenList = [];
try {
const v2List = data.v2;
v2List.forEach((token) => {
const chainInfo = STARGATE_CHAIN_INFO.filter(
(chain) => chain.chainName.toUpperCase() === token.chainKey.toUpperCase(),
);
if (chainInfo && chainInfo.length > 0) {
processedTokenList.push({ ...token, endpointID: chainInfo[0].endpointID });
}
});
} catch (e) {
console.log(`Failed to retrieve Stargate API data at ${new Date().getTime()}`, e);
}
return processedTokenList;
}

async getMesonConfigs() {
Expand Down

0 comments on commit 16d752a

Please sign in to comment.