Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pot page layout to support voting mechanisms #260

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
afbc147
wip
carina-akaia Nov 22, 2024
cf29fbe
wip
carina-akaia Nov 22, 2024
ee3405e
wip
carina-akaia Nov 22, 2024
e6a7cc5
wip
carina-akaia Nov 25, 2024
6016e5c
chore: Format
carina-akaia Nov 25, 2024
b75939a
Merge branch 'staging' of https://github.com/PotLock/potlock-nextjs-a…
carina-akaia Nov 25, 2024
757dda4
wip
carina-akaia Nov 25, 2024
d1c3874
chore: Format
carina-akaia Nov 25, 2024
305c4b2
Merge branch 'staging' of https://github.com/PotLock/potlock-nextjs-a…
carina-akaia Nov 25, 2024
2c9f0e8
wip
carina-akaia Nov 25, 2024
94b37ff
wip
carina-akaia Nov 25, 2024
5179f79
Fix runtime errors
carina-akaia Nov 25, 2024
3f633bc
Update API bindings and docs
carina-akaia Nov 26, 2024
adda0ab
Fix type errors
carina-akaia Nov 26, 2024
36ff754
Disallow ts-nocheck
carina-akaia Nov 26, 2024
9ce6de9
wip
carina-akaia Nov 26, 2024
7e36117
wip
carina-akaia Nov 26, 2024
d5a9bfe
Update styles
carina-akaia Nov 26, 2024
80dbc7b
Update styles
carina-akaia Nov 26, 2024
16477af
Update styles
carina-akaia Nov 26, 2024
eee6186
chore: Format
carina-akaia Nov 26, 2024
bcdee1e
wip
carina-akaia Nov 26, 2024
d7aa58c
wip
carina-akaia Nov 27, 2024
8f62d52
chore: Format
carina-akaia Nov 27, 2024
e6f84a3
wip
carina-akaia Nov 27, 2024
eaf814d
wip
carina-akaia Nov 27, 2024
9dce6dd
wip
carina-akaia Nov 27, 2024
76c1cbb
Merge branch 'staging' of https://github.com/PotLock/potlock-nextjs-a…
carina-akaia Nov 27, 2024
aeeaf4b
wip
carina-akaia Nov 27, 2024
886a98e
wip
carina-akaia Nov 27, 2024
7345df1
wip
carina-akaia Nov 28, 2024
e791d0e
wip
carina-akaia Nov 28, 2024
193a6ad
wip
carina-akaia Nov 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2018,
"ecmaVersion": 2022,
"sourceType": "module"
},
"env": {
Expand Down Expand Up @@ -34,6 +34,7 @@
],
"@typescript-eslint/no-explicit-any": 1,
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/ban-ts-comment": "error",
"prettier/prettier": [
"error",
{
Expand All @@ -55,9 +56,7 @@
"allowSeparatedGroups": true
}
],
// turn on errors for missing imports
"import/no-unresolved": "error",
// "import/no-named-as-default-member": "off",
"import/order": [
"error",
{
Expand Down Expand Up @@ -91,6 +90,9 @@
}
}
],
"import/no-default-export": [
"warn"
],
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"warn",
Expand All @@ -99,5 +101,23 @@
"varsIgnorePattern": "^_"
}
]
}
},
"overrides": [
{
"files": [
"src/pages/**/*"
],
"rules": {
"import/no-default-export": "off"
}
},
{
"files": [
"src/app/**/{page,layout,not-found}.tsx"
],
"rules": {
"import/no-default-export": "off"
}
}
]
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@
"dontcare",
"fastnear",
"foodbank",
"formkit",
"graylisted",
"hookform",
"kubb",
"linktree",
"METAPOOL",
"mpdao",
"NADABOT",
"narwallets",
Expand All @@ -36,6 +38,7 @@
"POTLOCK",
"precommit",
"ramper",
"RPGF",
"sessionid",
"shadcn",
"socialdb",
Expand Down
32 changes: 13 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
# PotLock - NextJS frontend
# PotLock Next

PotLock frontend application built on NextJS featuring project exploration, pages, donations, and Pots (quadratic funding for now) on the NEAR Blockchain

To-Do

- Feeds
- Campaigns
- Lists

The backlog to the NextJS App can be found at <https://potlock.org/next-backlog>

You can access BOS PotLock version using one of the environments below:
Expand All @@ -18,7 +12,8 @@ You can access BOS PotLock version using one of the environments below:

You can see original features <https://potlock.notion.site/All-Features-Potlock-NextJS-App-5f543fa8b31840aa88bf5b8cf57ead3d?pvs=4>

Core contracts can be found at <https://github.com/PotLock/core> and documentation <https://docs.potlock.io/contracts/contracts-overview>
Core contracts can be found at <https://github.com/PotLock/core>
Contract documentation: <https://docs.potlock.io/contracts/contracts-overview>

## Development

Expand All @@ -38,10 +33,9 @@ yarn dev

Open [http://localhost:3000](http://localhost:3000) in your browser.

### DJango Indexer API
### Backend ( Indexer API )

This project is using an indexer service.
You can access its docs here: <https://github.com/PotLock/django-indexer?tab=readme-ov-file#api-endpoints>
Swagger docs: <https://test-dev.potlock.io/api/schema/swagger-ui/#/>

**URI**: <http://ec2-100-27-57-47.compute-1.amazonaws.com/api/v1>

Expand All @@ -59,16 +53,17 @@ aspects of the application within each module:
├── global.d.ts <--- # Globally available type definitions
├── [ common ] <--- # Low-level foundation of the app, containing endpoint bindings,
│ │ # utility libraries, reusable primitives, and assets, used in layouts and
│ │ # business logic across the codebase. MUST NOT contain business logic by itself.
│ │ # AKA "shared" ( see link 2. )
│ │
│ ├── constants.ts <--- # Static reusable values, e.g.
│ │ export const DEFAULT_NETWORK = "testnet"
│ │ export const MAX_GAS = 100
│ │ export const NATIVE_TOKEN_ID = "near";
│ │ export const MAX_GAS = 100;
│ │
│ ├── [ api ] <--- # Facilitates network interaction with backend(s)
│ ├── [ api ] <--- # Basic network and data layer
│ │
│ ├── [ assets ] <--- # Globally used assets, e.g. images or icons
│ │
Expand All @@ -88,7 +83,6 @@ aspects of the application within each module:
├── [ modules ] <--- # Business logic units broken down into categories. Simply put, this is
│ │ # a collection of directories that contain code implementing specific
│ │ # groups of app use cases and are named after functionalities they provide.
Expand All @@ -101,14 +95,16 @@ aspects of the application within each module:
│ │
│ ├── [ profile ] <--- # A feature-specific module
│ │ │
│ │ ├── index.ts <--- # Module entry point for public exports ( available for external use )
│ │ │
│ │ ├── constants.ts <--- # Module-specific static reusable values, e.g.
│ │ │ export const POTLOCK_REGISTRY_LIST_ID = 1
│ │ │ export const PUBLIC_GOODS_REGISTRY_LIST_ID = 1
│ │ │
│ │ ├── models.ts <--- # Feature state definitions ( See link 3. )
│ │ │ # If this file grows over 300 LoC, consider turning it into a directory
│ │ │ # with the same name by applying code-splitting techniques.
│ │ │
│ │ ├── types.d.ts <--- # Module-specific shared types and interfaces
│ │ ├── types.ts <--- # Module-specific shared types and interfaces
│ │ │
│ │ ├── [ components ] <--- # Feature-specific React components
│ │ │
Expand All @@ -123,13 +119,11 @@ aspects of the application within each module:
├── [ pages ] <--- # Entry point of the application.
│ # Follows Nextjs Pages routing specification ( see link 1. )
└── [ store ] <--- # Shared application state root.
# Uses Rematch state management library, based on Redux.

Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "@potlock/nextjs-frontend",
"name": "@potlock/next",
"description": "Decentralized funding stack for public goods",
"version": "2.0.0",
"packageManager": "[email protected]",
"private": true,
Expand Down Expand Up @@ -57,6 +58,7 @@
"@radix-ui/react-radio-group": "^1.1.3",
"@radix-ui/react-scroll-area": "^1.1.0",
"@radix-ui/react-select": "^2.1.2",
"@radix-ui/react-separator": "^1.1.0",
"@radix-ui/react-slot": "^1.1.0",
"@radix-ui/react-switch": "^1.0.3",
"@radix-ui/react-toast": "^1.2.2",
Expand Down Expand Up @@ -148,4 +150,4 @@
"vite-tsconfig-paths": "^4.3.2",
"vitest": "^1.6.0"
}
}
}
6 changes: 1 addition & 5 deletions src/common/api/indexer/types.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
ListRegistration,
Pot,
PotApplication,
} from "./internal/client.generated";
import { ListRegistration, Pot, PotApplication } from "./internal/client.generated";

/**
*! Heads Up!
Expand Down
6 changes: 5 additions & 1 deletion src/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Big } from "big.js";
import { utils } from "near-api-js";
import { Metadata } from "next";

import { NETWORK } from "./_config";
import { ChronologicalSortOrderVariant } from "./types";

export const DEBUG = Boolean(process.env.NEXT_PUBLIC_DEBUG);
Expand Down Expand Up @@ -46,7 +47,7 @@ export const NATIVE_TOKEN_ID = "near";
export const NATIVE_TOKEN_DECIMALS = 24;

// List ID of PotLock Public Goods Registry
export const POTLOCK_REGISTRY_LIST_ID = 1;
export const PUBLIC_GOODS_REGISTRY_LIST_ID = 1;

// Separates contract_id and method_name in ProviderId
export const PROVIDER_ID_DELIMITER = ":";
Expand All @@ -73,6 +74,9 @@ export const IPFS_NEAR_SOCIAL_THUMBNAIL_URL =

export const IPFS_NEAR_SOCIAL_URL = "https://ipfs.near.social/ipfs/";

export const VOTING_BASED_POT_IDS =
NETWORK === "mainnet" ? ["mpdao.v1.potfactory.potlock.near"] : [];

export const CHRONOLOGICAL_SORT_OPTIONS: {
label: string;
value: ChronologicalSortOrderVariant;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
CampaignDonation,
CampaignFormFields,
DirectCampaignDonationArgs,
} from "./interfaces/campaign.interfaces";
} from "./interface";

export const contractApi = naxiosInstance.contractApi({
contractId: CAMPAIGNS_CONTRACT_ACCOUNT_ID,
Expand Down
5 changes: 5 additions & 0 deletions src/common/contracts/core/campaigns/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import * as campaignsClient from "./client";

export * from "./interface.d";

export { campaignsClient };
14 changes: 4 additions & 10 deletions src/common/contracts/core/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import * as campaign from "./campaigns";
import * as pot from "./pot";
import * as potFactory from "./pot-factory";

export * from "./interfaces/campaign.interfaces";
export * from "./campaigns";
export * from "./donation";
export * from "./interfaces/lists.interfaces";
export * from "./interfaces/pot.interfaces";
export * from "./interfaces/pot-factory.interfaces";

export { pot, potFactory, campaign };
export * from "./lists";
export * from "./pot";
export * from "./pot-factory";
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { MemoryCache } from "@wpdas/naxios";

import { LISTS_CONTRACT_ACCOUNT_ID } from "@/common/_config";
import { naxiosInstance } from "@/common/api/near";
import { POTLOCK_REGISTRY_LIST_ID } from "@/common/constants";
import { PUBLIC_GOODS_REGISTRY_LIST_ID } from "@/common/constants";
import { floatToYoctoNear } from "@/common/lib";
import { AccountId } from "@/common/types";

Expand All @@ -13,7 +13,7 @@ import {
Registration,
RegistrationStatus,
UpdateRegistration,
} from "./interfaces/lists.interfaces";
} from "./interface";

/**
* NEAR Contract API
Expand All @@ -32,7 +32,7 @@ export const getLists = () => contractApi.view<{}, List[]>("get_lists");

export const get_admin_list = () =>
contractApi.view<{}, List[]>("list_admins_by_list_id", {
args: { list_id: POTLOCK_REGISTRY_LIST_ID, accountId: "harrydhillon.near" },
args: { list_id: PUBLIC_GOODS_REGISTRY_LIST_ID, accountId: "harrydhillon.near" },
});

export const create_list = ({
Expand Down Expand Up @@ -188,7 +188,7 @@ export const get_upvoted_lists_for_account = (args: { account_id: string }) =>
* Get Registrations for a list
*/
export const getRegistrations = (
args: { list_id: number } = { list_id: POTLOCK_REGISTRY_LIST_ID },
args: { list_id: number } = { list_id: PUBLIC_GOODS_REGISTRY_LIST_ID },
) => {
return contractApi.view<typeof args, Registration[]>(
"get_registrations_for_list",
Expand All @@ -210,7 +210,7 @@ export const getRegistration = async (args: { list_id?: number; registrant_id: s
},
);
const registration = registrations.find(
(registration) => registration.list_id === args.list_id || POTLOCK_REGISTRY_LIST_ID,
(registration) => registration.list_id === args.list_id || PUBLIC_GOODS_REGISTRY_LIST_ID,
);
return registration;
};
Expand Down
5 changes: 5 additions & 0 deletions src/common/contracts/core/lists/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import * as listsClient from "./client";

export * from "./interface.d";

export { listsClient };
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,7 @@ import { naxiosInstance } from "@/common/api/near";
import { FULL_TGAS } from "@/common/constants";
import { ByAccountId } from "@/common/types";

import {
PotArgs,
PotDeploymentResult,
PotFactoryConfig,
} from "./interfaces/pot-factory.interfaces";

export type { PotDeploymentResult };
import { PotArgs, PotDeploymentResult, PotFactoryConfig } from "./interface";

export const contractApi = naxiosInstance.contractApi({
contractId: POT_FACTORY_CONTRACT_ACCOUNT_ID,
Expand Down
5 changes: 5 additions & 0 deletions src/common/contracts/core/pot-factory/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import * as potFactoryClient from "./client";

export * from "./interface.d";

export { potFactoryClient };
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
PotDonation,
PotDonationArgs,
UpdatePotArgs,
} from "./interfaces/pot.interfaces";
} from "./interface";

/**
* NEAR Contract API
Expand Down
5 changes: 5 additions & 0 deletions src/common/contracts/core/pot/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import * as potClient from "./client";

export * from "./interface.d";

export { potClient };
2 changes: 1 addition & 1 deletion src/common/contracts/core/sybil/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Provider } from "near-api-js/lib/providers";
import { SYBIL_CONTRACT_ACCOUNT_ID } from "@/common/_config";
import { naxiosInstance } from "@/common/api/near";
import { FULL_TGAS, ONE_HUNDREDTH_NEAR, TWO_HUNDREDTHS_NEAR } from "@/common/constants";
import { AccountId } from "@/common/types";

import { GetHumanScoreInput, HumanScoreResponse } from "./interface/is-human";
import { Config } from "./interface/lib";
Expand All @@ -17,7 +18,6 @@ import {
UpdateProviderInput,
} from "./interface/providers";
import {
AccountId,
GetStampsForAccountIdInput,
GetUsersForStampInput,
StampExternal,
Expand Down
2 changes: 0 additions & 2 deletions src/common/contracts/core/sybil/interface/stamps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,3 @@ export type GetUsersForStampInput = {
from_index?: number;
limit?: number;
};

export type AccountId = string;
2 changes: 2 additions & 0 deletions src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,5 @@ export enum ChronologicalSortOrder {
}

export type ChronologicalSortOrderVariant = keyof typeof ChronologicalSortOrder;

export type BasicRequirement = { title: string; isSatisfied: boolean };
Loading
Loading