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

feat: add setAdditionalAddresses to enable dynamic addresses #188

Closed
wants to merge 2 commits into from
Closed
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
16 changes: 15 additions & 1 deletion lib/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,22 @@
import testnet from "../data/addresses.testnet.json";
import { ParamChainName, ParamSymbol, ParamType } from "./types";

interface Address {
address: string;
category: string;
chain_id: number;
chain_name: ParamChainName;
type: ParamType;
}

let additionalAddresses: Address[] = [];

export const setAdditionalAddresses = (addresses: Address[]) => {
additionalAddresses = addresses;
}

Check failure on line 19 in lib/addresses.ts

View workflow job for this annotation

GitHub Actions / lint

Insert `;`
Comment on lines +17 to +19
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a missing semicolon at the end of the assignment.

It's important to maintain consistency in code style and adhere to the project's linting rules.

-  additionalAddresses = addresses
+  additionalAddresses = addresses;
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export const setAdditionalAddresses = (addresses: Address[]) => {
additionalAddresses = addresses;
}
export const setAdditionalAddresses = (addresses: Address[]) => {
additionalAddresses = addresses;
}
Tools
GitHub Check: lint

[failure] 19-19:
Insert ;


export const getAddress = (type: ParamType, network: ParamChainName, symbol?: ParamSymbol) => {
const networks = [...testnet, ...mainnet];
const networks = [...additionalAddresses, ...testnet, ...mainnet];
let address;
if (type !== "zrc20" && symbol) {
throw new Error("Symbol is only supported when ParamType is zrc20");
Expand Down
4 changes: 3 additions & 1 deletion lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@
| "USDT.BSC"
| "USDT.ETH";
export type ParamChainName =
| "bsc_mainnet"

Check failure on line 17 in lib/types.ts

View workflow job for this annotation

GitHub Actions / lint

Union type ParamChainName members must be sorted
| "bsc_testnet"
| "btc_mainnet"
| "btc_testnet"
| "eth_mainnet"
| "eth_developnet"
| "mumbai_testnet"
| "sepolia_testnet"
| "zeta_mainnet"
| "zeta_testnet";
| "zeta_testnet"
| "zeta_developnet";
Comment on lines +22 to +27
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sort the members of the ParamChainName enum.

The enum members should be sorted alphabetically to maintain readability and prevent potential merge conflicts.

export type ParamChainName =
  | "bsc_mainnet"
  | "bsc_testnet"
  | "btc_mainnet"
  | "btc_testnet"
  | "eth_developnet"
  | "eth_mainnet"
  | "mumbai_testnet"
  | "sepolia_testnet"
  | "zeta_developnet"
  | "zeta_mainnet"
  | "zeta_testnet";
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
| "eth_developnet"
| "mumbai_testnet"
| "sepolia_testnet"
| "zeta_mainnet"
| "zeta_testnet";
| "zeta_testnet"
| "zeta_developnet";
| "bsc_mainnet"
| "bsc_testnet"
| "btc_mainnet"
| "btc_testnet"
| "eth_developnet"
| "eth_mainnet"
| "mumbai_testnet"
| "sepolia_testnet"
| "zeta_developnet"
| "zeta_mainnet"
| "zeta_testnet";

export type ParamType =
| "connector"
| "erc20Custody"
Expand Down
Loading