forked from d-EURO/dapp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.config.ts
More file actions
127 lines (110 loc) · 3.81 KB
/
app.config.ts
File metadata and controls
127 lines (110 loc) · 3.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
"use client";
import { ApolloClient, InMemoryCache } from "@apollo/client";
import { cookieStorage, createConfig, createStorage, http } from "@wagmi/core";
import { injected, coinbaseWallet, walletConnect } from "@wagmi/connectors";
import { mainnet, polygon, Chain } from "@wagmi/core/chains";
import axios from "axios";
import { Address } from "viem";
export type ConfigEnv = {
landing: string;
app: string;
api: string;
ponder: string;
wagmiId: string;
alchemyApiKey: string;
chain: string;
network: {
mainnet: string;
polygon: string;
};
};
// DEV: Loaded with defaults, not needed for now.
// if (!process.env.NEXT_PUBLIC_WAGMI_ID) throw new Error("Project ID is not defined");
// if (!process.env.NEXT_PUBLIC_RPC_URL_MAINNET) throw new Error("RPC URL for at least mainnet, not available");
// if (process.env.NEXT_PUBLIC_CHAIN_NAME == "polygon" && !process.env.NEXT_PUBLIC_RPC_URL_POLYGON)
// throw new Error("RPC URL for polygon (testnet), not available");
// Config
export const CONFIG: ConfigEnv = {
landing: process.env.NEXT_PUBLIC_LANDINGPAGE_URL ?? "https://deuro.com",
app: process.env.NEXT_PUBLIC_APP_URL ?? "https://app.deuro.com",
api: process.env.NEXT_PUBLIC_API_URL ?? "https://api.deuro.com",
ponder: process.env.NEXT_PUBLIC_PONDER_URL ?? "https://ponder.deuro.com",
wagmiId: process.env.NEXT_PUBLIC_WAGMI_ID ?? "",
alchemyApiKey: process.env.NEXT_PUBLIC_ALCHEMY_API_KEY ?? "",
chain: process.env.NEXT_PUBLIC_CHAIN_NAME ?? "mainnet",
network: {
mainnet: process.env.NEXT_PUBLIC_RPC_URL_MAINNET ?? "https://eth-mainnet.g.alchemy.com/v2",
polygon: process.env.NEXT_PUBLIC_RPC_URL_POLYGON ?? "https://polygon-mainnet.g.alchemy.com/v2",
}
};
const PRINT_CONFIG = (): ConfigEnv => {
const printConfig = { ...CONFIG};
printConfig.wagmiId = TRUNCATE_STRING(printConfig.wagmiId, 5, 5);
printConfig.alchemyApiKey = TRUNCATE_STRING(printConfig.alchemyApiKey, 5, 5);
return printConfig;
}
const TRUNCATE_STRING = (text: string, startCount: number, endCount: number): string => {
if (text.length <= startCount + endCount) return text;
const first = text.slice(0, startCount);
const last = text.slice(-endCount);
return `${first}...${last}`;
}
// PRINT CONFIGURATION PROFILE
console.log("YOU ARE USING THIS CONFIG PROFILE:");
console.log(PRINT_CONFIG());
// CONFIG CHAIN
export const CONFIG_CHAIN = (): Chain => {
return CONFIG.chain === "polygon" ? polygon : mainnet;
}
// CONFIG RPC
export const CONFIG_RPC = (): string => {
return CONFIG.chain === "polygon" ? `${CONFIG.network.polygon}/${CONFIG.alchemyApiKey}` : `${CONFIG.network.mainnet}/${CONFIG.alchemyApiKey}`;
}
// PONDER CLIENT
export const PONDER_CLIENT = new ApolloClient({
uri: CONFIG.ponder,
cache: new InMemoryCache(),
});
// DEURO API CLIENT
export const DEURO_API_CLIENT = axios.create({
baseURL: CONFIG.api,
});
// WAGMI CONFIG
export const WAGMI_CHAIN = CONFIG_CHAIN();
export const WAGMI_METADATA = {
name: "dEURO",
description: "dEURO Frontend Application",
url: CONFIG.landing,
icons: ["https://avatars.githubusercontent.com/u/37784886"],
};
export const WAGMI_CONFIG = createConfig({
chains: [WAGMI_CHAIN],
transports: {
[WAGMI_CHAIN.id]: http(CONFIG_RPC()),
},
batch: {
multicall: {
wait: 200,
},
},
connectors: [
walletConnect({ projectId: CONFIG.wagmiId, metadata: WAGMI_METADATA, showQrModal: false }),
injected({ shimDisconnect: true }),
coinbaseWallet({
appName: WAGMI_METADATA.name,
appLogoUrl: WAGMI_METADATA.icons[0],
}),
],
ssr: true,
storage: createStorage({
storage: cookieStorage,
}),
});
// MINT POSITION BLACKLIST
export const MINT_POSITION_BLACKLIST: Address[] = ["0x98725eE62833096C1c9bE26001F3cDA9a6241EF3"];
export const POSITION_NOT_BLACKLISTED = (addr: Address): boolean => {
const r = MINT_POSITION_BLACKLIST.filter((p) => {
return p.toLowerCase() === addr.toLowerCase();
});
return r.length == 0;
};