Skip to content

Enc typescript testing #286

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

Open
wants to merge 31 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
090c21e
typescript testing
Dec 2, 2024
ada4f5e
all file changed to ts
Dec 6, 2024
70329f1
error fixes
Dec 9, 2024
395f928
algorand, ethereum, solana issue fixed
Dec 10, 2024
1fbfdaf
index issue fixed
Dec 10, 2024
45a3153
aptos,near,sui,tron ts file added
Dec 10, 2024
8457a1b
aptos, tron issue fixed
Dec 10, 2024
e4f3955
wallectcosmos issue fixed
Dec 10, 2024
ce07844
walletfireblock
Dec 10, 2024
fb62bc6
issue fixed
Dec 10, 2024
f143049
cosmos,fireblocks,steller,ton,xrpl fie changed to ts
Dec 11, 2024
ee72acf
issue fixed
Dec 11, 2024
d9ad8d4
Ethereum signtransaction issues fixed
T3KRAJ Dec 13, 2024
502de48
issue fixed
Dec 13, 2024
6de05e4
Merge branch 'ENC_typescript-testing' of https://github.com/expand-ne…
Dec 13, 2024
a57cc70
phamton wallet issues fixed
T3KRAJ Dec 13, 2024
e4cadbb
Merge branch 'ENC_typescript-testing' of https://github.com/expand-ne…
T3KRAJ Dec 13, 2024
174ab5b
Merge branch 'develop' of https://github.com/expand-network/sdk-nodej…
Dec 13, 2024
08ab221
Merge branch 'ENC_typescript-testing' of https://github.com/expand-ne…
Dec 13, 2024
7ec287a
bitcoin, stacks file changed to ts
Dec 13, 2024
15f1092
config file changed
Dec 13, 2024
8b69984
WalletStacks file added
Dec 16, 2024
af86574
type issue fixed in WalletTon
T3KRAJ Dec 16, 2024
29bde87
walleissues fixed
Dec 17, 2024
4b49047
dydx file changed
Dec 17, 2024
15ed871
dydx file issue fixed
Dec 17, 2024
43a134f
json removed from config.json import
T3KRAJ Dec 18, 2024
4dd2b40
typescript issue fixed
Dec 19, 2024
1c29fb4
circle test convert into typescript
Dec 19, 2024
9c04e2c
schema code changed
Dec 23, 2024
42fb49e
type issues fixed
T3KRAJ Jan 2, 2025
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
51 changes: 51 additions & 0 deletions configuration/common.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import config from './config';

type ChainConfig = {
chains: {
[key: string]: {
localName: string;
chainName: string;
chainSymbol: string;
};
};
};

type Options = {
chainId?: string | number | null;
chainSymbol?: string | null;
};

const getChainIdFromChainSymbol = async (chainSymbol: string): Promise<string | null> => {
const upperCaseChainSymbol = chainSymbol.toUpperCase();

for (const chain in (config as ChainConfig).chains) {
if ((config as ChainConfig).chains[chain].chainSymbol.toUpperCase() === upperCaseChainSymbol) {
return chain;
}
}

return null;
}

export const getChainId = async (options: Options): Promise<string | null> => {
/*
* This function returns the appropriate chainId
* for the given combination of chainId and chainSymbol
*/

let chainId: string | null = options.chainId ? options.chainId.toString() : null;
const chainSymbol: string | null = options.chainSymbol ? options.chainSymbol.toUpperCase() : null;

if (chainId === null && chainSymbol === null) {
// By default setting it to EVM based chains
chainId = "1";
} else if (chainId === null && chainSymbol != null) {
// Fetch the equivalent chain ID from the configuration file
chainId = await getChainIdFromChainSymbol(chainSymbol);
} else if (chainId != null) {
// Ensure chainId is a string
chainId = chainId.toString();
}

return chainId;
};
2 changes: 2 additions & 0 deletions configuration/config.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

{
"chains": {
"1": {
Expand Down Expand Up @@ -444,3 +445,4 @@
}
}
}

Loading
Loading