summaryrefslogtreecommitdiff
path: root/constants
diff options
context:
space:
mode:
Diffstat (limited to 'constants')
-rw-r--r--constants/colors.ts51
-rw-r--r--constants/config.ts67
-rw-r--r--constants/constants.ts24
-rw-r--r--constants/contracts.ts109
-rw-r--r--constants/index.ts5
-rw-r--r--constants/routes.ts11
6 files changed, 267 insertions, 0 deletions
diff --git a/constants/colors.ts b/constants/colors.ts
new file mode 100644
index 0000000..6f07a2c
--- /dev/null
+++ b/constants/colors.ts
@@ -0,0 +1,51 @@
+// import { useSettingsStore } from "../store/useSettingsStore";
+
+export type ColorScheme = typeof lightColors;
+
+export const useThemeColors = (): ColorScheme => {
+ // const isDarkMode = useSettingsStore((s) => s.isDarkMode);
+ // return isDarkMode ? darkColors : lightColors;
+ return lightColors;
+};
+
+export const lightColors = {
+ background: "#F7F7F7",
+ text: "#171717",
+ card: "#FFFFFF",
+ border: "#E5E5E5",
+ primary: "#1997FC",
+ secondary: "#737373", //"#4B5563",
+ toastBackground: "#171717",
+ toastText: "#FFFFFF",
+ toastSuccess: "#12BA03",
+ toastError: "#EF4444",
+ skeletonBase: "#ebebeb",
+ skeletonHighlight: "#f5f5f5",
+ button: "#171717",
+ buttonText: "#F7F7F7",
+ iconBorder: "#D4D4D4",
+ navBorder: "#D4D4D4",
+ switchBackground: "#E5E5E5",
+ switchThumb: "#FFFFFF",
+};
+
+export const darkColors = {
+ background: "#121212",
+ text: "#F3F3F3",
+ card: "#1F1F1F",
+ border: "#323232", //"#2A2A2A",
+ primary: "#1997FC",
+ secondary: "#9CA3AF",
+ toastBackground: "#F3F3F3",
+ toastText: "#121212",
+ toastSuccess: "#22C55E",
+ toastError: "#EF4444",
+ skeletonBase: "#374151",
+ skeletonHighlight: "#4B5563",
+ button: "#F7F7F7",
+ buttonText: "#171717",
+ iconBorder: "#FAFAFA",
+ navBorder: "#323232",
+ switchBackground: "#E5E5E5",
+ switchThumb: "#1F1F1F",
+};
diff --git a/constants/config.ts b/constants/config.ts
new file mode 100644
index 0000000..6fa09b6
--- /dev/null
+++ b/constants/config.ts
@@ -0,0 +1,67 @@
+import { JsonRpcProvider, WebSocketProvider } from "ethers";
+import { ETHEREUM_NETWORK } from "../constants";
+
+const isLocal = false;
+
+const INFURA_API = process.env.EXPO_PUBLIC_INFURA_API!;
+const INFURA_API_SECRET_KEY = process.env.EXPO_PUBLIC_INFURA_API_SECRET_KEY!;
+const NETWORK = process.env.EXPO_PUBLIC_NETWORK!;
+const ETHERSCAN_API_KEY = process.env.EXPO_PUBLIC_ETHERSCAN_API_KEY!;
+const requiredVars = [
+ INFURA_API,
+ INFURA_API_SECRET_KEY,
+ NETWORK,
+ ETHERSCAN_API_KEY,
+];
+
+const missingVar = requiredVars.find((v) => !v);
+
+if (missingVar) {
+ throw new Error(
+ "Missing required environment variables. Check your .env file.",
+ );
+}
+
+export const WEBSOCKET_URL = `wss://${NETWORK}.infura.io/ws/v3/${INFURA_API}`;
+
+export const PROVIDER_URL = isLocal
+ ? "http://localhost:8545"
+ : `https://${NETWORK}.infura.io/v3/${INFURA_API}`;
+
+export const MAINNET_PROVIDER_URL = `https://mainnet.infura.io/v3/${INFURA_API}`;
+
+export const getEtherscanBaseUrl = () => {
+ console.log("NETWORK", NETWORK);
+ return NETWORK === ETHEREUM_NETWORK.MAINNET
+ ? "https://api.etherscan.io/api"
+ : `https://api-${NETWORK}.etherscan.io/api`;
+};
+
+export const httpProvider = new JsonRpcProvider(
+ `https://${NETWORK}.infura.io/v3/${INFURA_API}`,
+);
+export const wsProvider = new WebSocketProvider(WEBSOCKET_URL);
+
+export const getEthTxUrl = (
+ walletAddress: string,
+ page: number = 1,
+ pageSize: number = 20,
+) =>
+ `${getEtherscanBaseUrl()}?module=account&action=txlist&address=${walletAddress}&startblock=0&endblock=99999999&page=${page}&offset=${pageSize}&sort=desc&apikey=${ETHERSCAN_API_KEY}`;
+
+export const getTokenTxUrl = (
+ walletAddress: string,
+ page: number = 1,
+ pageSize: number = 20,
+) =>
+ `${getEtherscanBaseUrl()}?module=account&action=tokentx&address=${walletAddress}&startblock=0&endblock=99999999&page=${page}&offset=${pageSize}&sort=desc&apikey=${ETHERSCAN_API_KEY}`;
+
+export const getTokenIcon = (address: string) =>
+ `https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/${address}/logo.png`;
+
+export const getInternalTxUrl = (
+ walletAddress: string,
+ page: number = 1,
+ pageSize: number = 20,
+) =>
+ `${getEtherscanBaseUrl()}?module=account&action=txlistinternal&address=${walletAddress}&startblock=0&endblock=99999999&page=${page}&offset=${pageSize}&sort=desc&apikey=${ETHERSCAN_API_KEY}`;
diff --git a/constants/constants.ts b/constants/constants.ts
new file mode 100644
index 0000000..477a2e7
--- /dev/null
+++ b/constants/constants.ts
@@ -0,0 +1,24 @@
+import { ImageSourcePropType } from "react-native";
+import EthLogo from "../assets/eth-logo.png";
+import UsdcLogo from "../assets/usdc-logo.png";
+import linkLogo from "../assets/link-logo.png";
+
+export const ETHEREUM_NETWORK = {
+ MAINNET: "mainnet",
+ SEPOLIA: "sepolia",
+ LOCAL: "local",
+} as const;
+
+export const DEFAULT_HD_PATH = "m/44'/60'/0'/0/0";
+
+export const ETH_PRICE_URL =
+ "https://api.coingecko.com/api/v3/simple/price?ids=ethereum&vs_currencies=usd";
+
+export const TOKEN_ICONS: Record<string, ImageSourcePropType> = {
+ ETH: EthLogo,
+ USDC: UsdcLogo,
+ // USDT: "https://assets.coingecko.com/coins/images/325/thumb/Tether.png?1696501661",
+ // DAI: "https://assets.coingecko.com/coins/images/9956/thumb/Badge_Dai.png?1696509996", //"https://cryptologos.cc/logos/multi-collateral-dai-dai-logo.png",
+ LINK: linkLogo, //"https://assets.coingecko.com/coins/images/877/thumb/chainlink-new-logo.png?1696502009", //"https://cryptologos.cc/logos/chainlink-link-logo.png",
+ // default: "https://via.placeholder.com/36",
+};
diff --git a/constants/contracts.ts b/constants/contracts.ts
new file mode 100644
index 0000000..9c02a4a
--- /dev/null
+++ b/constants/contracts.ts
@@ -0,0 +1,109 @@
+import { ETHEREUM_NETWORK } from "../constants";
+
+type ContractAddresses = Record<string, string>;
+type NetworkKey = keyof typeof ETHEREUM_NETWORK;
+
+export const ERC20_ABI = [
+ {
+ type: "function",
+ name: "balanceOf",
+ inputs: [{ name: "owner", type: "address" }],
+ outputs: [{ name: "", type: "uint256" }],
+ stateMutability: "view",
+ },
+ {
+ type: "function",
+ name: "decimals",
+ inputs: [],
+ outputs: [{ name: "", type: "uint8" }],
+ stateMutability: "view",
+ },
+ {
+ type: "function",
+ name: "transfer",
+ inputs: [
+ { name: "to", type: "address" },
+ { name: "value", type: "uint256" },
+ ],
+ outputs: [{ name: "", type: "bool" }],
+ stateMutability: "nonpayable",
+ },
+ {
+ type: "event",
+ name: "Transfer",
+ inputs: [
+ { name: "from", type: "address", indexed: true },
+ { name: "to", type: "address", indexed: true },
+ { name: "value", type: "uint256", indexed: false },
+ ],
+ anonymous: false,
+ },
+];
+
+export const AZIMUTH_ABI = [
+ "function getOwner(uint32 _point) view returns (address)",
+ "function getOwnedPoints(address _whose) view returns (uint32[])",
+];
+
+const CONTRACT_ADDRESSES: Record<NetworkKey, ContractAddresses> = {
+ MAINNET: {
+ azimuth: "0x223c067f8cf28ae173ee5cafea60ca44c335fecb",
+ ecliptic: "0x33EeCbf908478C10614626A9D304bfe18B78DD73",
+ polls: "0x0",
+ claims: "0x0",
+ linearStarRelease: "0x86cd9cd0992f04231751e3761de45cecea5d1801",
+ conditionalStarRelease: "0x8c241098c3d3498fe1261421633fd57986d74aea",
+ urbit_L2: "0x1111111111111111111111111111111111111111",
+ usdc: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606EB48",
+ usdt: "0xdac17f958d2ee523a2206206994597c13d831ec7",
+ dai: "0x6b175474e89094c44da98b954eedeac495271d0f",
+ link: "0x514910771af9ca656af840dff83e8264ecf986ca", // ?
+ },
+ SEPOLIA: {
+ azimuth: "0xF07cD672D61453c29138c8db5b44fC9FA84811B5",
+ ecliptic: "0x2E35a61198C383212CeF06C22f1E81B6b097135C",
+ polls: "0x3A3a06199Dc537FB56A6975A8B12A8eD7fCbf897",
+ claims: "0xdB164DBEF321e7DE938809fE35A5A8A928c4F4df",
+ linearStarRelease: "0x0",
+ conditionalStarRelease: "0x0",
+ urbit_L2: "0x0",
+ usdc: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",
+ usdt: "0xaa8e23fb1079ea71e0a56f48a2aa51851d8433d0",
+ dai: "0x776b6fc2ed15d6bb5fc32e0c89de68683118c62a",
+ link: "0x779877A7B0D9E8603169DdbD7836e478b4624789",
+ },
+ LOCAL: {
+ azimuth: "0x0",
+ ecliptic: "0x0",
+ polls: "0x0",
+ claims: "0x0",
+ linearStarRelease: "0x0",
+ conditionalStarRelease: "0x0",
+ urbit_L2: "0x0",
+ usdc: "0x0",
+ usdt: "0x0",
+ dai: "0x0",
+ link: "0x0",
+ },
+};
+
+const mapNetworkStringToKey = (network: string): NetworkKey => {
+ switch (network) {
+ case "mainnet":
+ return "MAINNET";
+ case "sepolia":
+ return "SEPOLIA";
+ case "local":
+ return "LOCAL";
+ default:
+ return "SEPOLIA";
+ }
+};
+
+const currentNetworkKey = mapNetworkStringToKey(
+ process.env.EXPO_PUBLIC_NETWORK!,
+);
+
+console.log("currentNetworkKey", currentNetworkKey);
+
+export const CONTRACT = CONTRACT_ADDRESSES[currentNetworkKey];
diff --git a/constants/index.ts b/constants/index.ts
new file mode 100644
index 0000000..ad2c758
--- /dev/null
+++ b/constants/index.ts
@@ -0,0 +1,5 @@
+export * from "./contracts";
+export * from "./constants";
+export * from "./colors";
+export * from "./config";
+export * from "./routes";
diff --git a/constants/routes.ts b/constants/routes.ts
new file mode 100644
index 0000000..697f4fc
--- /dev/null
+++ b/constants/routes.ts
@@ -0,0 +1,11 @@
+export const ROUTES = {
+ PASSKEY_SETUP: "PasskeySetup",
+ LOGIN: "Login",
+ HOME: "Home",
+ SEND: "Send",
+ RECEIVE: "Receive",
+ HISTORY: "TransactionHistory",
+ MAIN_TABS: "MainTabs",
+ AUTH: "Auth",
+ APP: "App",
+} as const;