Skip to content

Commit 0015764

Browse files
Merge pull request goatstone#60 from JoseHerminioCollas/main
Update to use Polygon network
2 parents 8af3c7f + 5adaffe commit 0015764

File tree

3 files changed

+61
-10
lines changed

3 files changed

+61
-10
lines changed

docs/bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/env.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// public/env.js
22
window.env = {
3-
network: "sepolia",
4-
platformFee: "0.0012",
3+
network: "polygon",
4+
platformFee: "3.0",
55
};

src/config.ts

Lines changed: 58 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,25 @@ import contractArtifactSepolia from "../artifacts/contracts/AaartoNFTV4.sol/Aaar
55
* get values from it, otherwise use default values
66
*/
77
export type WindowEnv = { platformFee: string; network: string };
8+
type Network = "sepolia" | "polygon" | "amoy";
89

910
let 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
1415
let 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;
1723
if (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
}
2228
if (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-
4697
export default config;

0 commit comments

Comments
 (0)