Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test #2124

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft

test #2124

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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"checkVaultTokenDecimals": "ts-node -r dotenv/config ./scripts/checkVaultTokenDecimals.ts && prettier --write ./src/config/vault/*.json",
"checkZapAddresses": "ts-node -r dotenv/config ./scripts/checkZapAddresses.ts",
"makeExcludeConfig": "ts-node -r dotenv/config ./scripts/makeExcludeConfig.ts",
"fetchStargatePaths": "ts-node -r dotenv/config ./scripts/fetchStargatePaths.ts",
"prepare": "husky install",
"tsc": "tsc",
"tsc-watch": "tsc --watch",
Expand Down
34 changes: 18 additions & 16 deletions scripts/common/addressbook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@ export const getChainAddressBook = memoize(
address: bookToken.address,
decimals: bookToken.decimals,
symbol: bookToken.symbol,
buyUrl: null,
website: bookToken.website || null,
description: bookToken.description || null,
documentation: bookToken.documentation || null,
buyUrl: undefined,
website: bookToken.website || undefined,
description: bookToken.description || undefined,
documentation: bookToken.documentation || undefined,
risks: [],
type: 'erc20',
};
} else if (tokenId === nativeSymbol) {
Expand All @@ -65,10 +66,10 @@ export const getChainAddressBook = memoize(
address: bookToken.address,
decimals: bookToken.decimals,
symbol: nativeSymbol,
buyUrl: null,
website: bookToken.website || null,
description: bookToken.description || null,
documentation: bookToken.documentation || null,
buyUrl: undefined,
website: bookToken.website || undefined,
description: bookToken.description || undefined,
documentation: bookToken.documentation || undefined,
type: 'native',
};
} else {
Expand All @@ -79,10 +80,10 @@ export const getChainAddressBook = memoize(
address: 'native',
decimals: bookToken.decimals,
symbol: nativeSymbol,
buyUrl: null,
website: bookToken.website || null,
description: bookToken.description || null,
documentation: bookToken.documentation || null,
buyUrl: undefined,
website: bookToken.website || undefined,
description: bookToken.description || undefined,
documentation: bookToken.documentation || undefined,
type: 'native',
};
}
Expand All @@ -94,10 +95,11 @@ export const getChainAddressBook = memoize(
address: bookToken.address,
decimals: bookToken.decimals,
symbol: bookToken.symbol,
buyUrl: null,
website: bookToken.website || null,
description: bookToken.description || null,
documentation: bookToken.documentation || null,
buyUrl: undefined,
website: bookToken.website || undefined,
description: bookToken.description || undefined,
documentation: bookToken.documentation || undefined,
risks: [],
type: 'erc20',
};
}
Expand Down
6 changes: 3 additions & 3 deletions scripts/common/chains.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { config } from '../../src/config/config';
import { ChainEntity } from '../../src/features/data/entities/chain';

export type AppChainId = keyof typeof config;
export type AppChainId = ChainEntity['id'];

export const chainsByAppId: Record<AppChainId, ChainEntity> = Object.entries(config).reduce(
(acc, [chainId, chainConfig]) => {
Expand All @@ -12,7 +12,7 @@ export const chainsByAppId: Record<AppChainId, ChainEntity> = Object.entries(con
};
return acc;
},
{}
{} as Record<AppChainId, ChainEntity>
);

export const allChainIds: AppChainId[] = Object.keys(chainsByAppId);
export const allChainIds: AppChainId[] = Object.keys(chainsByAppId) as AppChainId[];
73 changes: 39 additions & 34 deletions scripts/common/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ async function getChainTokens(chain: ChainEntity): Promise<TokenEntity[]> {
oracleId: chain.walletSettings.nativeCurrency.symbol,
address: 'native',
decimals: chain.walletSettings.nativeCurrency.decimals,
buyUrl: null,
website: null,
description: null,
documentation: null,
buyUrl: undefined,
website: undefined,
description: undefined,
documentation: undefined,
},
{
type: 'native',
Expand All @@ -43,10 +43,10 @@ async function getChainTokens(chain: ChainEntity): Promise<TokenEntity[]> {
oracleId: chain.walletSettings.nativeCurrency.symbol,
address: 'native',
decimals: chain.walletSettings.nativeCurrency.decimals,
buyUrl: null,
website: null,
description: null,
documentation: null,
buyUrl: undefined,
website: undefined,
description: undefined,
documentation: undefined,
},
];
}
Expand All @@ -65,10 +65,11 @@ async function getVaultTokensForChain(chain: ChainEntity): Promise<TokenEntity[]
address: vault.tokenAddress,
decimals: vault.tokenDecimals,
providerId: vault.tokenProviderId,
buyUrl: null,
website: null,
description: null,
documentation: null,
risks: [],
buyUrl: undefined,
website: undefined,
description: undefined,
documentation: undefined,
});
}

Expand All @@ -81,10 +82,11 @@ async function getVaultTokensForChain(chain: ChainEntity): Promise<TokenEntity[]
oracleId: vault.earnedToken,
address: vault.earnedTokenAddress,
decimals: vault.earnedTokenDecimals || 18,
buyUrl: null,
website: null,
description: null,
documentation: null,
risks: [],
buyUrl: undefined,
website: undefined,
description: undefined,
documentation: undefined,
});
}

Expand All @@ -105,10 +107,11 @@ async function getBoostTokensForChain(chain: ChainEntity): Promise<TokenEntity[]
oracleId: boost.earnedOracleId || boost.earnedToken,
address: boost.earnedTokenAddress,
decimals: boost.earnedTokenDecimals || 18,
buyUrl: null,
website: null,
description: null,
documentation: null,
risks: [],
buyUrl: undefined,
website: undefined,
description: undefined,
documentation: undefined,
});
}

Expand All @@ -129,10 +132,11 @@ async function getMinterTokensForChain(chain: ChainEntity): Promise<TokenEntity[
oracleId: minter.depositToken.oracleId || minter.depositToken.symbol,
address: minter.depositToken.contractAddress,
decimals: minter.depositToken.decimals || 18,
buyUrl: null,
website: null,
description: null,
documentation: null,
risks: [],
buyUrl: undefined,
website: undefined,
description: undefined,
documentation: undefined,
});
}

Expand All @@ -145,10 +149,11 @@ async function getMinterTokensForChain(chain: ChainEntity): Promise<TokenEntity[
oracleId: minter.mintedToken.oracleId || minter.mintedToken.symbol,
address: minter.mintedToken.contractAddress,
decimals: minter.mintedToken.decimals || 18,
buyUrl: null,
website: null,
description: null,
documentation: null,
risks: [],
buyUrl: undefined,
website: undefined,
description: undefined,
documentation: undefined,
});
}

Expand Down Expand Up @@ -232,25 +237,25 @@ function addToken(
export async function getTokenById(
id: TokenEntity['id'],
chainId: ChainEntity['id']
): Promise<TokenEntity | null> {
): Promise<TokenEntity | undefined> {
const { byId } = await getTokensForChain(chainId);
const address = byId[id];

if (!address) return null;
if (!address) return undefined;

return getTokenByAddress(address, chainId);
}

export async function getTokenByAddress(
address: TokenEntity['address'],
chainId: ChainEntity['id']
): Promise<TokenEntity | null> {
): Promise<TokenEntity | undefined> {
const { byAddress } = await getTokensForChain(chainId);
const token = byAddress[address.toLowerCase()];
return token || null;
return token || undefined;
}

export async function getNativeToken(chainId: ChainEntity['id']): Promise<TokenNative | null> {
export async function getNativeToken(chainId: ChainEntity['id']): Promise<TokenNative | undefined> {
const token = await getTokenById('native', chainId);
if (!token || !isTokenNative(token)) {
throw new Error(`No native token found for chain ${chainId}`);
Expand All @@ -260,7 +265,7 @@ export async function getNativeToken(chainId: ChainEntity['id']): Promise<TokenN

export async function getWrappedNativeToken(
chainId: ChainEntity['id']
): Promise<TokenErc20 | null> {
): Promise<TokenErc20 | undefined> {
const token = await getTokenById('wnative', chainId);
if (!token || !isTokenErc20(token)) {
console.warn(token);
Expand Down
Loading