Skip to content

Commit

Permalink
Add setAdditionalAddresses to enable dynamic addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
gartnera committed Jun 27, 2024
1 parent 6785f39 commit cc6b034
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
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 mainnet from "../data/addresses.mainnet.json";
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 `;`

export const getAddress = (type: ParamType, network: ParamChainName, symbol?: ParamSymbol) => {
const networks = [...testnet, ...mainnet];
const networks = [...testnet, ...mainnet, ...additionalAddresses];
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 @@ -19,10 +19,12 @@ export type ParamChainName =
| "btc_mainnet"
| "btc_testnet"
| "eth_mainnet"
| "eth_developnet"
| "mumbai_testnet"
| "sepolia_testnet"
| "zeta_mainnet"
| "zeta_testnet";
| "zeta_testnet"
| "zeta_developnet";
export type ParamType =
| "connector"
| "erc20Custody"
Expand Down

0 comments on commit cc6b034

Please sign in to comment.