Skip to content

Commit

Permalink
Merge branch 'main' into shazarre/delegatee_registration_form
Browse files Browse the repository at this point in the history
  • Loading branch information
shazarre committed Oct 2, 2024
2 parents 4f8a6e8 + 0f2273b commit fd1c90d
Show file tree
Hide file tree
Showing 20 changed files with 797 additions and 518 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ jobs:
install:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
**/node_modules
Expand All @@ -38,8 +38,8 @@ jobs:
runs-on: ubuntu-latest
needs: [install]
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
**/node_modules
Expand All @@ -55,8 +55,8 @@ jobs:
runs-on: ubuntu-latest
needs: [install]
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
**/node_modules
Expand All @@ -77,8 +77,8 @@ jobs:
runs-on: ubuntu-latest
needs: [install]
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
**/node_modules
Expand All @@ -92,8 +92,8 @@ jobs:
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
**/node_modules
Expand Down
7 changes: 2 additions & 5 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn lint-staged
yarn prettier
yarn lint-staged --quiet
yarn prettier
2 changes: 1 addition & 1 deletion next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
"homepage": "https://github.com/celo-org/celo-mondo",
"dependencies": {
"@celo/abis": "^11.0.0",
"@celo/compliance": "^1.0.23",
"@headlessui/react": "^1.7.18",
"@metamask/jazzicon": "https://github.com/jmrossy/jazzicon#7a8df28974b4e81129bfbe3cab76308b889032a6",
"@metamask/post-message-stream": "6.1.2",
"@metamask/providers": "10.2.1",
"@rainbow-me/rainbowkit": "2.1.1",
"@rainbow-me/rainbowkit": "2.1.6",
"@tanstack/react-query": "^5.28.9",
"@tanstack/react-table": "^8.15.0",
"@vercel/analytics": "^1.3.0",
Expand All @@ -30,15 +31,14 @@
"formik": "2.4.6",
"micromark": "^4.0.0",
"micromark-extension-gfm-table": "^2.0.0",
"next": "14.1.4",
"next": "14.2.10",
"octokit": "^4.0.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-minimal-pie-chart": "^8.4.0",
"react-toastify": "^10.0.5",
"viem": "2.12.1",
"vitest": "^2.1.1",
"wagmi": "2.9.6",
"viem": "2.21.8",
"wagmi": "2.12.12",
"yaml": "^2.4.2",
"zod": "^3.23.8"
},
Expand Down Expand Up @@ -67,7 +67,8 @@
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"tsx": "^4.7.1",
"typescript": "^5.4.3"
"typescript": "^5.4.3",
"vitest": "^2.1.1"
},
"resolutions": {
"bignumber.js": "9.1.2",
Expand All @@ -88,5 +89,5 @@
"prettier": "prettier --write ./src",
"checks": "yarn typecheck && yarn lint && yarn test && yarn prettier && yarn build:app"
},
"packageManager": "yarn@4.5.0"
"packageManager": "yarn@4.1.1"
}
Binary file added public/logos/delegatees/0xGoldo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/logos/delegatees/Areta-Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/logos/delegatees/SovSignal.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/logos/delegatees/oliseh.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed public/logos/valora.jpg
Binary file not shown.
5 changes: 4 additions & 1 deletion src/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'react-toastify/dist/ReactToastify.css';
import { ErrorBoundary } from 'src/components/errors/ErrorBoundary';
import { Footer } from 'src/components/nav/Footer';
import { Header } from 'src/components/nav/Header';
import { LegalRestrict } from 'src/components/police';
import { WagmiContext } from 'src/config/wagmi';
import { TransactionModal } from 'src/features/transactions/TransactionModal';
import { useIsSsr } from 'src/utils/ssr';
Expand All @@ -17,7 +18,9 @@ export function App({ children }: PropsWithChildren<any>) {
<ErrorBoundary>
<SafeHydrate>
<WagmiContext>
<BodyLayout>{children}</BodyLayout>
<LegalRestrict>
<BodyLayout>{children}</BodyLayout>
</LegalRestrict>
<TransactionModal />
<ToastContainer transition={Zoom} position="bottom-right" />
</WagmiContext>
Expand Down
36 changes: 36 additions & 0 deletions src/app/police/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { headers } from 'next/headers';
import { NextResponse, type NextRequest } from 'next/server';
import { logger } from 'src/utils/logger';

export function GET(request: NextRequest) {
const headerList = headers();

const country = request.geo?.country || (headerList.get('x-vercel-ip-country') as string);
const region = request.geo?.region || (headerList.get('x-vercel-ip-country-region') as string);

logger.info('country', country, region);

if (isForbiddenLand(country, region)) {
return new NextResponse(null, { status: 451 });
}

return new NextResponse(null, { status: 202 });
}
const RESTRICTED_COUNTRIES = new Set(['KP', 'IR', 'CU', 'SY']);

// https://www.iso.org/obp/ui/#iso:code:3166:UA although listed with UA prefix. the header/api recieved that and just used the number
const crimea = '43';
const luhansk = '09';
const donetska = '14';
//https://en.wikipedia.org/wiki/Russian-occupied_territories_of_Ukraine
const RESTRICED_SUBREGION: Record<string, Set<string>> = {
UA: new Set([crimea, luhansk, donetska]),
};

function isForbiddenLand(iso3166Country: string, iso3166Region: string) {
const iso3166CountryUppercase = iso3166Country?.toUpperCase();
return (
RESTRICTED_COUNTRIES.has(iso3166CountryUppercase) ||
RESTRICED_SUBREGION[iso3166CountryUppercase]?.has(iso3166Region)
);
}
55 changes: 55 additions & 0 deletions src/components/police.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { OFAC_SANCTIONS_LIST_URL, SANCTIONED_ADDRESSES } from '@celo/compliance';
import { PropsWithChildren, useEffect } from 'react';
import { readFromCache, writeToCache } from 'src/utils/localSave';
import { useAccount, useDisconnect } from 'wagmi';

export function LegalRestrict(props: PropsWithChildren) {
usePolice();
return props.children;
}

function usePolice() {
const { address, isConnected } = useAccount();
const { disconnect } = useDisconnect();

useEffect(() => {
if (isConnected && address) {
isSanctionedAddress(address).then((isSanctioned) => {
if (isSanctioned) {
disconnect();
alert('The Address is under OFAC Sanctions');
}
});
fetch('/police').then((response) => {
if (response.status === 451) {
disconnect();
alert('The Region is under Sanction');
}
});
}
}, [isConnected, address, disconnect]);
}

const DAY = 24 * 60 * 60 * 1000;

export async function isSanctionedAddress(address: string): Promise<boolean> {
const cache = readFromCache(OFAC_SANCTIONS_LIST_URL);
if (cache && cache.ts + DAY > Date.now()) {
return cache.data.includes(address.toLowerCase());
}

const sanctionedAddresses: string[] = await fetch(OFAC_SANCTIONS_LIST_URL)
.then((x) => x.json())
.catch(() => SANCTIONED_ADDRESSES); // fallback if github is down or something.

if (process.env.NODE_ENV !== 'production' && process.env.TEST_SANCTIONED_ADDRESS) {
sanctionedAddresses.push(process.env.TEST_SANCTIONED_ADDRESS);
}

writeToCache(
OFAC_SANCTIONS_LIST_URL,
sanctionedAddresses.map((x) => x.toLowerCase()),
);

return isSanctionedAddress(address);
}
48 changes: 48 additions & 0 deletions src/config/delegates.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
{
"0x3e737AD3234a127066043D5Df2ABF7adDEC79c2b": {
"name": "0xGoldo",
"address": "0x3e737AD3234a127066043D5Df2ABF7adDEC79c2b",
"logoUri": "/logos/delegatees/0xGoldo.jpg",
"date": "2024-09-08",
"links": {
"website": "https://forum.celo.org/u/0xgoldo/summary"
},
"interests": ["Community", "Defi", "Decentralization", "Transparency"],
"description": "Hi Celorians! I am a member of the Celo Guardians team (formerly known as 'CGP Editors'), the decentralized working group that is helping to mantain and organize the Celo Governance. I am also part of the Moderators team, a role that require myself to be involved and up to date around everything happening on Celo and his ecosystem. As a Celo Delegate, my motivation is rooted in the desire to support a decentralized, inclusive, and environmentally conscious financial ecosystem. I believe in Celo’s mission to bring prosperity to all by leveraging blockchain technology, particularly in providing financial tools to underserved communities globally."
},
"0x8b37a5Af68D315cf5A64097D96621F64b5502a22": {
"name": "Areta",
"address": "0x8b37a5Af68D315cf5A64097D96621F64b5502a22",
"logoUri": "/logos/delegatees/Areta-Logo.png",
"date": "2024-09-05",
"links": {
"website": "https://www.areta.io/",
"twitter": "https://x.com/areta_io"
},
"interests": ["Governance Design", "Ecosystem Growth", "Decentralization"],
"description": "Areta Governance specializes in supporting DAOs and foundations to establish and grow decentralized governance structures. We develop tailored solutions in governance inception and optimization, ecosystem growth, and service provider selection. Our connected investment bank with deep strategic expertise, enables us to serve our partners holistically, rather than working in isolated governance silos. ​We have had the privilege to work alongside industry leaders such as Uniswap, Arbitrum, Safe, Aave, and dYdX."
},
"0x3c3Eb5C41720D555F81eD554e901edD0a6aF228C": {
"name": "Stake Capital",
"address": "0x3c3Eb5C41720D555F81eD554e901edD0a6aF228C",
Expand All @@ -11,6 +34,31 @@
"interests": ["Proof-of-Stake", "High Availability", "Infrastructure", "Web3 Investment"],
"description": "Stake Capital is a trusted and experienced blockchain investment firm, actively contributing to the blockchain ecosystem since 2016. With expertise in venture capital, incubation, acceleration, and validation, we ensure robust participation in governance through our mainnet validation for top projects and our involvement in testnets for emerging infrastructures. Our commitment to excellence and transparency makes us a reliable partner to delegate your voting power, helping to secure and innovate within the Celo network."
},
"0x2D7d6Ec6198ADFD5850D00BD601958F6E316b05E": {
"name": "Sov",
"address": "0x2D7d6Ec6198ADFD5850D00BD601958F6E316b05E",
"logoUri": "/logos/delegatees/SovSignal.jpeg",
"date": "2024-08-31",
"links": {
"website": "https://forum.celo.org/u/sov/summary",
"twitter": "https://x.com/SovereignSignal;"
},
"interests": [
"Ecosystem Development",
"Strategic Partnerships",
"Grants and Incentives Programs"
],
"description": "Experienced Web3 grants and ecosystem builder, bringing cross-DAO insights to Celo governance"
},
"0xa88df1011E9aF811e7dc67396133f69a3CAFf072": {
"name": "Oliseh Genesis",
"address": "0xa88df1011E9aF811e7dc67396133f69a3CAFf072",
"logoUri": "/logos/delegatees/oliseh.jpg",
"date": "2024-05-09",
"links": {},
"interests": ["Discovery", "Engaged", "Calm", "Love"],
"description": "Oliseh is unbaised , belives in Celo and more so a passive builder. Got into the Celo ecosystem through Celo Africa Dao but everyday building new products for the ecosystem"
},
"0x657D07095b082BB71ebD93F549f407A97f49094F": {
"name": "0xMims",
"address": "0x657D07095b082BB71ebD93F549f407A97f49094F",
Expand Down
Loading

0 comments on commit fd1c90d

Please sign in to comment.