-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
108 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
export * from "./address.tools"; | ||
export * from "./addresses"; | ||
export * from "./types"; | ||
|
||
export { default as testnet } from "../data/addresses.testnet.json"; | ||
export { default as mainnet } from "../data/addresses.mainnet.json"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export declare type ParamSymbol = "USDC.BSC" | "USDC.ETH" | "BTC.BTC" | "BNB.BSC" | "USDT.ETH" | "USDT.BSC" | "ETH.ETH" | "USDC" | "gETH" | "tMATIC" | "tBTC" | "tBNB"; | ||
Check failure on line 1 in lib/types.ts GitHub Actions / build
|
||
export declare type ParamChainName = "eth_mainnet" | "bsc_mainnet" | "btc_mainnet" | "zeta_mainnet" | "zeta_testnet" | "goerli_testnet" | "bsc_testnet" | "mumbai_testnet" | "btc_testnet"; | ||
Check failure on line 2 in lib/types.ts GitHub Actions / build
|
||
export declare type ParamType = "tss" | "systemContract" | "connector" | "zrc20" | "uniswapv2Factory" | "wZetaContract" | "uniswapv2Router02" | "fungibleModule" | "zetaToken" | "erc20Custody" | "tssUpdater" | "pauser"; | ||
Check failure on line 3 in lib/types.ts GitHub Actions / build
|
||
|
||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,4 +79,4 @@ | |
}, | ||
"types": "./dist/lib/index.d.ts", | ||
"version": "0.0.8" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import testnet from "../data/addresses.testnet.json"; | ||
import mainnet from "../data/addresses.mainnet.json"; | ||
|
||
const extractUniqueValues = (data: any[], key: string): string[] => { | ||
const allValues = data.filter((item) => item[key] !== undefined).map((item) => item[key].toString()); | ||
return [...new Set(allValues)]; | ||
}; | ||
|
||
const generateTypesForKeys = (keys: string[]) => { | ||
const networks = [...mainnet, ...testnet]; | ||
|
||
let typeDefs = ""; | ||
|
||
keys.forEach((key) => { | ||
const uniqueValues = extractUniqueValues(networks, key); | ||
if (uniqueValues.length > 0) { | ||
const isNumeric = uniqueValues.every((value) => !isNaN(Number(value))); | ||
const formattedValues = isNumeric ? uniqueValues.join(" | ") : `"${uniqueValues.join('" | "')}"`; | ||
|
||
typeDefs += `export type Param${toCamelCase(key, true)} = ${formattedValues};\n`; | ||
} | ||
}); | ||
|
||
console.log(typeDefs); | ||
}; | ||
|
||
// Modify this function to handle underscores and capitalize each word | ||
const toCamelCase = (string: string, capitalizeFirst: boolean = false) => { | ||
return string | ||
.split("_") | ||
.map((word, index) => { | ||
if (index === 0) { | ||
return capitalizeFirst ? word.charAt(0).toUpperCase() + word.slice(1) : word; | ||
} | ||
return word.charAt(0).toUpperCase() + word.slice(1); | ||
}) | ||
.join(""); | ||
}; | ||
|
||
const keysToGenerate = ["symbol", "chain_name", "type"]; | ||
|
||
generateTypesForKeys(keysToGenerate); |