@@ -5,19 +5,25 @@ import contractArtifactSepolia from "../artifacts/contracts/AaartoNFTV4.sol/Aaar
55 * get values from it, otherwise use default values
66 */
77export type WindowEnv = { platformFee : string ; network : string } ;
8+ type Network = "sepolia" | "polygon" | "amoy" ;
89
910let config : any ;
1011// TODO test only, remove the next line for production
11- // const windowEnv: WindowEnv = { network: "sepolia ", platformFee: "0.002 " };
12+ // const windowEnv: WindowEnv = { network: "polygon ", platformFee: "3.0 " };
1213// window.env = windowEnv;
1314// set default values
1415let platformFee = "0.001" ;
15- let network = "sepolia" ;
16- let chainName = "Sepolia Ether" ;
16+ let network : Network = "sepolia" ;
17+ const chainNames : Record < Network , string > = {
18+ sepolia : "Sepolia Ether" ,
19+ polygon : "Polygon Mainnet" ,
20+ amoy : "Polygon Amoy Testnet" ,
21+ } ;
22+ let chainName = chainNames . sepolia ;
1723if ( window . env ) {
1824 platformFee = window . env . platformFee ;
19- network = window . env . network ;
20- chainName = network === "sepolia" ? "Sepolia Ether" : "Polygon" ;
25+ network = window . env . network as Network ;
26+ chainName = chainNames [ network ] ;
2127}
2228if ( network === "sepolia" ) {
2329 config = {
@@ -33,14 +39,59 @@ if (network === "sepolia") {
3339 chainName,
3440 rpcUrls : [ "https://rpc.sepolia.org" ] ,
3541 nativeCurrency : {
36- name : chainName ,
42+ name : "SEP" ,
3743 symbol : "SEP" ,
3844 decimals : 18 ,
3945 } ,
4046 blockExplorerUrls : [ "https://sepolia.etherscan.io" ] ,
4147 } ,
4248 ] ,
4349 } ;
50+ } else if ( network === "polygon" ) {
51+ config = {
52+ chainNameDisplay : chainName ,
53+ contractArtifact : contractArtifactSepolia ,
54+ platformFee,
55+ contractAddress : "0x03a9423E9Aac42E9F991D292F8e074808D9ABE7f" ,
56+ chainIDBigInt : 137n ,
57+ chainIDHex : "0x89" ,
58+ ethRequestParams : [
59+ {
60+ chainId : "0x89" ,
61+ chainName,
62+ rpcUrls : [ "https://polygon-rpc.com/" ] ,
63+ nativeCurrency : {
64+ name : "MATIC" ,
65+ symbol : "MATIC" ,
66+ decimals : 18 ,
67+ } ,
68+ blockExplorerUrls : [ "https://polygonscan.com/" ] ,
69+ } ,
70+ ] ,
71+ } ;
72+ } else if ( network === "amoy" ) {
73+ config = {
74+ chainNameDisplay : chainName ,
75+ contractArtifact : contractArtifactSepolia ,
76+ platformFee,
77+ contractAddress : "0xXXX" ,
78+ chainIDBigInt : 80002n ,
79+ chainIDHex : "0x13882" ,
80+ ethRequestParams : [
81+ {
82+ chainId : "0x13882" ,
83+ chainName,
84+ rpcUrls : [ "https://rpc-amoy.polygon.technology/" ] ,
85+ nativeCurrency : {
86+ name : "MATIC" ,
87+ symbol : "MATIC" ,
88+ decimals : 18 ,
89+ } ,
90+ blockExplorerUrls : [ "https://amoy.polygonscan.com/" ] ,
91+ } ,
92+ ] ,
93+ } ;
94+ } else {
95+ throw "Chain config does not exist" ;
4496}
45-
4697export default config ;
0 commit comments