Skip to content

Commit

Permalink
Merge branch 'main' into bug_fixing_#221
Browse files Browse the repository at this point in the history
  • Loading branch information
aahna-ashina authored Jan 31, 2024
2 parents 73838f2 + c578b03 commit 3850d1c
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @nation3/developer-level-4
* @nation3/developer-level-4 @nation3/developer-level-5
24 changes: 20 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
# Nation3 App ☁️🇺🇳

![Vercel](https://vercelbadge.vercel.app/api/nation3/app)

<a href="https://github.com/nation3/app/graphs/contributors" alt="Contributors">
<img src="https://img.shields.io/github/contributors/nation3/app" /></a>
<a href="https://github.com/nation3/app/pulse" alt="Activity">
<a href="https://github.com/nation3/app/graphs/contributors" alt="Contributors"> <img src="https://img.shields.io/github/contributors/nation3/app" /></a> <a href="https://github.com/nation3/app/pulse" alt="Activity">
<img src="https://img.shields.io/github/commit-activity/m/nation3/app" /></a>

---
Expand Down Expand Up @@ -49,6 +46,25 @@ Solve this by switching to the _Goerli Test Network_ in MetaMask:

> <img width="328" alt="Screen Shot 2022-05-21 at 11 03 28 AM" src="https://user-images.githubusercontent.com/95955389/169633167-3570d17b-e7a9-4726-a377-e4a4ce455f5e.png">
## Testing against the Sepolia Ethereum testnet

Add Sepolia testnet variables to your local development environment:
```
cp .env.sepolia .env.local
```

Start the development server:
```
yarn dev
```

Once you go to http://localhost:42069, you will see the message "Nation3 uses Sepolia as its preferred network":

> <img width="801" alt="Screenshot 2024-01-25 at 13 09 56" src="https://github.com/nation3/app/assets/42999269/6121fde4-8b5c-4f8c-be50-531723121770">
Solve this by switching to the Sepolia Test Network in MetaMask:

> <img width="315" alt="Screenshot 2024-01-25 at 14 45 18" src="https://github.com/nation3/app/assets/42999269/3331f209-1d48-4b6b-8e71-f1ca53a37394">
## Run the smart contracts locally

Expand Down
3 changes: 1 addition & 2 deletions contracts/deployments/goerli.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@
"nationPassportNFTIssuer": "0x8c16926819AB30B8b29A8E23F5C230d164337093",
"nationPassportAgreementStatement": "By claiming a Nation3 passport I agree to the terms defined in the following URL",
"nationPassportAgreementURI": "https://bafkreiadlf3apu3u7blxw7t2yxi7oyumeuzhoasq7gqmcbaaycq342xq74.ipfs.dweb.link",
"nationPassportRequiredBalance": 2,
"nationPassportRevokeUnderBalance": 1.5
"nationPassportRequiredBalance": 2
}
3 changes: 1 addition & 2 deletions contracts/deployments/mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@
"nationPassportNFTIssuer": "0x279c0b6bfCBBA977eaF4ad1B2FFe3C208aa068aC",
"nationPassportAgreementStatement": "By claiming a Nation3 passport I agree to the terms defined in the following URL",
"nationPassportAgreementURI": "https://bafkreiadlf3apu3u7blxw7t2yxi7oyumeuzhoasq7gqmcbaaycq342xq74.ipfs.dweb.link",
"nationPassportRequiredBalance": 2,
"nationPassportRevokeUnderBalance": 1.5
"nationPassportRequiredBalance": 2
}
10 changes: 10 additions & 0 deletions contracts/deployments/sepolia.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"nationToken": "0x23Ca3002706b71a440860E3cf8ff64679A00C9d7",
"veNationToken": "0x8100e77899C24b0F7B516153F84868f850C034BF",
"balancerLPToken": "0x6417755C00d5c17DeC196Df00a6F151E448B1471",
"lpRewardsContract": "0x534AB4F195Ac166B78d9edCdbeA04802392711aA",
"nationPassportNFT": "0x11f30642277A70Dab74C6fAF4170a8b340BE2f98",
"nationPassportNFTIssuer": "0xdad32e13E73ce4155a181cA0D350Fee0f2596940",
"nationPassportAgreementStatement": "By claiming a Nation3 passport I agree to the terms defined in the following URL",
"nationPassportAgreementURI": "https://bafkreiadlf3apu3u7blxw7t2yxi7oyumeuzhoasq7gqmcbaaycq342xq74.ipfs.dweb.link"
}
5 changes: 5 additions & 0 deletions ui/.env.sepolia
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
NEXT_PUBLIC_CHAIN=sepolia
INFURA_ID=
ALCHEMY_ID=
ETHERSCAN_ID=
NFTSTORAGE_KEY=
5 changes: 5 additions & 0 deletions ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ or
```
cp .env.goerli .env.local
```
or
```
cp .env.sepolia .env.local
```


Build:
```
Expand Down
10 changes: 3 additions & 7 deletions ui/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ interface DeploymentConfig {
nationPassportNFTIssuer: string,
nationPassportAgreementStatement: string,
nationPassportAgreementURI: string,
nationPassportRequiredBalance: string,
nationPassportRevokeUnderBalance: string,
nationPassportRequiredBalance: string
}

interface Config {
Expand All @@ -29,8 +28,7 @@ interface Config {
nationPassportNFTIssuer: string,
nationPassportAgreementStatement: string,
nationPassportAgreementURI: string,
nationPassportRequiredBalance: number,
nationPassportRevokeUnderBalance: number,
nationPassportRequiredBalance: number
}

const chain = process.env.NEXT_PUBLIC_CHAIN || "goerli";
Expand All @@ -49,8 +47,7 @@ const config: Config = {
nationPassportNFTIssuer: defaultConfig.nationPassportNFTIssuer || zeroAddress,
nationPassportAgreementStatement: defaultConfig.nationPassportAgreementStatement || "",
nationPassportAgreementURI: defaultConfig.nationPassportAgreementURI || "",
nationPassportRequiredBalance: Number(defaultConfig.nationPassportRequiredBalance),
nationPassportRevokeUnderBalance: Number(defaultConfig.nationPassportRevokeUnderBalance)
nationPassportRequiredBalance: Number(defaultConfig.nationPassportRequiredBalance)
}

console.log(config)
Expand All @@ -70,6 +67,5 @@ export const {
nationPassportAgreementStatement,
nationPassportAgreementURI,
nationPassportRequiredBalance,
nationPassportRevokeUnderBalance
} = config

17 changes: 8 additions & 9 deletions ui/lib/passport-expiration-hook.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
import { ethers } from "ethers";
import { useMemo } from "react";
import { getPassportExpirationDate } from "./passport-expiration";
import { usePassportRevokeUnderBalance } from "./passport-nft";
import { useAccount } from "./use-wagmi";
import { useVeNationLock } from "./ve-token";
import { nationPassportRevokeUnderBalance } from "../lib/config";

export function usePassportExpirationDate(): Date | undefined {
const { address } = useAccount()
const { data: veNationLock } = useVeNationLock(address)

const threshold = ethers.BigNumber.from(String(nationPassportRevokeUnderBalance * 10 ** 18));
const { data: threshold } = usePassportRevokeUnderBalance()

return useMemo(() => {
if (!veNationLock) {
return undefined;
}
if (!veNationLock) {
return undefined;
}

const [lockAmount, lockEnd]: [ethers.BigNumber, ethers.BigNumber] = veNationLock;
return getPassportExpirationDate(lockAmount, lockEnd, threshold);
const [lockAmount, lockEnd]: [ethers.BigNumber, ethers.BigNumber] = veNationLock;
return getPassportExpirationDate(lockAmount, lockEnd, threshold);
}, [veNationLock, threshold]);
}
12 changes: 11 additions & 1 deletion ui/lib/passport-nft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function usePassport(address: any) {
const { data: id, isLoading: loadingID } = useContractRead(
{
...nftIssuerContractParams,
enable: Boolean(address)
enable: Boolean(address)
},
'passportId',
[address],
Expand All @@ -62,3 +62,13 @@ export function usePassport(address: any) {
const { loading, nft } = useNft(nationPassportNFT || '', id)
return { data: { id, nft }, isLoading: loadingID || loading }
}

export function usePassportRevokeUnderBalance() {
return useContractRead(
{
...nftIssuerContractParams,
},
'revokeUnderBalance',
undefined
)
}

0 comments on commit 3850d1c

Please sign in to comment.