Skip to content

Commit fc7a3e9

Browse files
chore: add polygon network
1 parent 71e9595 commit fc7a3e9

File tree

10 files changed

+37
-24
lines changed

10 files changed

+37
-24
lines changed

app/blockchain/.env.example

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
POLYGON_AMOY_RPC_URL=https://rpc-amoy.polygon.technology/
2-
POLYGON_RPC_URL=https://polygon-mainnet.infura.io/
31
PRIVATE_KEY=
4-
ETHERSCAN_API_KEY=
2+
ETHERSCAN_API_KEY=
3+
POLYGON_AMOY_RPC_URL=https://rpc-amoy.polygon.technology/
4+
POLYGON_RPC_URL=https://polygon-mainnet.infura.io
5+
MILKOMEDA_CARDANO_DEVNET=https://rpc-devnet-cardano-evm.c1.milkomeda.com
6+
MILKOMEDA_CARDANO_MAINNET=https://rpc-mainnet-algorand-rollup.a1.milkomeda.com

app/blockchain/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ dme: deploy-mock-erc20
1919
deploy-polygon-testnet:
2020
$(FORGE_SCRIPT) script/DeployFairFund.s.sol:DeployFairFund --rpc-url ${POLYGON_AMOY_RPC_URL} --private-key ${PRIVATE_KEY} ${BROADCAST} --verify --etherscan-api-key ${ETHERSCAN_API_KEY} $(LEGACY) -vvvv
2121

22+
deploy-polygon-mainnet:
23+
$(FORGE_SCRIPT) script/DeployFairFund.s.sol:DeployFairFund --rpc-url ${POLYGON_RPC_URL} --private-key ${PRIVATE_KEY} ${BROADCAST} --verify --etherscan-api-key ${ETHERSCAN_API_KEY} $(LEGACY) -vvvv
24+
25+
2226
mock-all: deploy-mock-fair-fund deploy-mock-erc20
2327

2428

app/blockchain/script/HelperConfig.s.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ contract HelperConfig is Script {
1313

1414
constructor() {
1515
if (block.chainid == 80002) {
16-
activeNetworkConfig = getPolygonTestnetConfig();
16+
activeNetworkConfig = getProdNetworkConfig();
1717
} else {
1818
activeNetworkConfig = getOrCreateAnvilEthConfig();
1919
}
2020
}
2121

22-
function getPolygonTestnetConfig() public view returns (NetworkConfig memory sepoliaNetworkConfig) {
23-
sepoliaNetworkConfig = NetworkConfig({deployerKey: vm.envUint("PRIVATE_KEY")});
22+
function getProdNetworkConfig() public view returns (NetworkConfig memory prodNetworkConfig) {
23+
prodNetworkConfig = NetworkConfig({deployerKey: vm.envUint("PRIVATE_KEY")});
2424
}
2525

2626
function getOrCreateAnvilEthConfig() public view returns (NetworkConfig memory anvilNetworkConfig) {

app/blockchain/src/FairFund.sol

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ contract FairFund is Ownable, ReentrancyGuard {
4747
error FairFund__TransferFailed(address token, address recepient, uint256 amount);
4848

4949
// State Variables //
50-
address private treasury;
50+
address private s_treasury;
5151
uint256 private s_fundingVaultIdCounter;
5252
mapping(uint256 fundingVaultId => address fundingVault) private s_fundingVaults;
5353
uint256 private s_platformFee;
@@ -60,7 +60,7 @@ contract FairFund is Ownable, ReentrancyGuard {
6060
* @param _platformFee The fee that will be charged by the platform for using the FairFund platform
6161
*/
6262
constructor(uint256 _platformFee) Ownable(msg.sender) {
63-
treasury = msg.sender;
63+
s_treasury = msg.sender;
6464
s_platformFee = _platformFee;
6565
}
6666

@@ -119,7 +119,7 @@ contract FairFund is Ownable, ReentrancyGuard {
119119
* @notice Modifies the platform fee (only callable by the owner)
120120
* @param _platformFee The new platform fee percentage to be set (i.e. 1 for 1% of amount every proposal will get.)
121121
*/
122-
function modityPlatformFee(uint256 _platformFee) external onlyOwner {
122+
function updatePlatformFee(uint256 _platformFee) external onlyOwner {
123123
s_platformFee = _platformFee;
124124
}
125125

@@ -133,16 +133,16 @@ contract FairFund is Ownable, ReentrancyGuard {
133133
}
134134
uint256 platformBalance = IERC20(token).balanceOf(address(this));
135135
if (platformBalance != 0) {
136-
bool success = IERC20(token).transfer(treasury, platformBalance);
136+
bool success = IERC20(token).transfer(s_treasury, platformBalance);
137137
if (!success) {
138-
revert FairFund__TransferFailed(token, treasury, platformBalance);
138+
revert FairFund__TransferFailed(token, s_treasury, platformBalance);
139139
}
140-
emit TransferTokens(token, treasury, platformBalance);
140+
emit TransferTokens(token, s_treasury, platformBalance);
141141
}
142142
}
143143

144144
function setTreasury(address _treasury) external onlyOwner {
145-
treasury = _treasury;
145+
s_treasury = _treasury;
146146
}
147147

148148
// Getters //
@@ -157,4 +157,8 @@ contract FairFund is Ownable, ReentrancyGuard {
157157
function getPlatformFee() external view returns (uint256) {
158158
return s_platformFee;
159159
}
160+
161+
function getTreasury() external view returns (address) {
162+
return s_treasury;
163+
}
160164
}

app/web-app/.env.example

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1+
# Get it from https://cloud.reown.com/
12
NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID=
23

34
# Website URL (Use http://localhost:3000 for local development)
45
NEXT_PUBLIC_WEBSITE_URL=http://localhost:3000
56

67
# NextAuth Secret (Generate a secure random string, e.g., via `openssl rand -base64 32`)
78
NEXTAUTH_SECRET=
9+
10+
# NextAuth URL (Use http://localhost:3000 for local development)
11+
NEXTAUTH_URL=http://localhost:3000
812
NEXTAUTH_URL=http://localhost:3000/
913
NEXTAUTH_URL_INTERNAL=http://localhost:3000/
14+
1015
NEXT_PUBLIC_WEBSITE_DESCRIPTION="FairFund is a blockchain based platform for community-driven funding. Users can deploy funding vaults, deposit funds, and submit proposals for funding. The platform uses a voting mechanism to decide which proposals receive funding."
1116
NEXT_PUBLIC_NETWORK=foundry
1217
NEXT_PUBLIC_SIGN_IN_STATEMENT="SignIn to FairFund."
1318

14-
# NextAuth URL (Use http://localhost:3000 for local development)
15-
NEXTAUTH_URL=http://localhost:3000
16-
1719
# PostgreSQL URLs (Default Docker-based setup uses 'development' password. Use your local PostgreSQL password if running locally)
1820
POSTGRES_PRISMA_URL="postgres://postgres:development@localhost:5432/dev-db"
1921
POSTGRES_URL_NON_POOLING="postgres://postgres:development@localhost:5432/dev-db"

app/web-app/src/blockchain/out/FairFund.sol/FairFund.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

app/web-app/src/blockchain/out/FundingVault.sol/FundingVault.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

app/web-app/src/wagmi/config/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { WagmiAdapter } from '@reown/appkit-adapter-wagmi';
22
import { cookieStorage, createStorage, http } from '@wagmi/core';
3-
import { foundry, polygonAmoy } from '@reown/appkit/networks';
3+
import { foundry, polygonAmoy, polygon } from '@reown/appkit/networks';
44

55
export const projectId = process.env.NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID;
66

@@ -18,6 +18,7 @@ export const wagmiAdapter = new WagmiAdapter({
1818
networks,
1919
transports: {
2020
[polygonAmoy.id]: http('https://rpc-amoy.polygon.technology/'),
21+
[polygon.id]: http('https://polygon.llamarpc.com'),
2122
[foundry.id]: http('http://localhost:8545'),
2223
},
2324
});

app/web-app/src/wagmi/provider/web3-modal.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
55
import { createAppKit } from '@reown/appkit/react';
66
import { cookieToInitialState, WagmiProvider, type Config } from 'wagmi';
77
import { siweConfig } from '@/wagmi/siwe';
8-
import { foundry, polygonAmoy } from '@reown/appkit/networks';
8+
import { foundry, polygonAmoy, polygon } from '@reown/appkit/networks';
99

1010
const queryClient = new QueryClient();
1111

@@ -24,9 +24,9 @@ const modal = createAppKit({
2424
networks:
2525
process.env.NEXT_PUBLIC_NETWORK === 'foundry'
2626
? [foundry]
27-
: [polygonAmoy],
27+
: [polygonAmoy, polygon],
2828
defaultNetwork:
29-
process.env.NEXT_PUBLIC_NETWORK === 'foundry' ? foundry : polygonAmoy,
29+
process.env.NEXT_PUBLIC_NETWORK === 'foundry' ? foundry : polygon,
3030
metadata,
3131
features: {
3232
analytics: false,

app/web-app/src/wagmi/siwe/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client';
22
import { createSIWEConfig, formatMessage } from '@reown/appkit-siwe';
33
import { getCsrfToken, getSession, signIn, signOut } from 'next-auth/react';
4-
import { foundry, polygonAmoy } from 'viem/chains';
4+
import { foundry, polygonAmoy, polygon } from 'viem/chains';
55

66
export const siweConfig = createSIWEConfig({
77
getMessageParams: async () => ({
@@ -10,7 +10,7 @@ export const siweConfig = createSIWEConfig({
1010
chains:
1111
process.env.NEXT_PUBLIC_NETWORK === 'foundry'
1212
? [foundry.id]
13-
: [polygonAmoy.id],
13+
: [polygonAmoy.id, polygon.id],
1414
statement: 'Sign In With Ethereum to prove you control this wallet.',
1515
}),
1616
createMessage: ({ address, ...args }) => formatMessage(args, address),

0 commit comments

Comments
 (0)