Skip to content

Feat/kleros app #1756

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

Merged
merged 29 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
32fbbfb
feat: kleros-app
Harman-singh-waraich Nov 21, 2024
f964a03
chore: update-prettier-eslint
Harman-singh-waraich Nov 21, 2024
a1484da
chore(kleros-app): migrate-to-vite
Harman-singh-waraich Nov 21, 2024
ecd7719
chore(kleros-app): remove-exports-field
Harman-singh-waraich Nov 21, 2024
e75a46b
fix: specify-temp-build-command-in-toml
Harman-singh-waraich Nov 21, 2024
4027336
fix: build-command
Harman-singh-waraich Nov 21, 2024
7c9a8ce
fix: polyfills
Harman-singh-waraich Nov 21, 2024
a90dd72
fix: externalize-wagmi
Harman-singh-waraich Nov 21, 2024
5fcf106
fix: update-wagmi
Harman-singh-waraich Nov 21, 2024
0071290
chore: eslint and other version bumps
jaybuidl Nov 21, 2024
944de42
chore(web-devtools): upgraded Next to 15, React to 19, removed unused…
jaybuidl Nov 21, 2024
f054afb
chore: update-dependencies
Harman-singh-waraich Nov 22, 2024
fda1f81
fix(web-devtools): field-type
Harman-singh-waraich Nov 22, 2024
88c1537
Merge pull request #1757 from kleros/chore/eslint-and-more-version-bump
Harman-singh-waraich Nov 22, 2024
8c15591
refactor: update-kleros-app-readme-and-package-json
Harman-singh-waraich Nov 25, 2024
bb2a083
chore: dedupe-dependencies
Harman-singh-waraich Nov 25, 2024
f9d5d28
fix(web-devtools): eslint-errors
Harman-singh-waraich Nov 25, 2024
819530a
feat(kleros-app): readme
Harman-singh-waraich Nov 25, 2024
df00e56
refactor(web-devtools): remove-ignore-comment
Harman-singh-waraich Nov 25, 2024
c3b5ca4
chore(web-devtools): netlify.toml
jaybuidl Nov 25, 2024
f2efd34
fix(web-devtools): downgrade-next-to-v14
Harman-singh-waraich Nov 25, 2024
2e88299
chore: package.json cleanup, preparing for release of kleros-app
jaybuidl Nov 25, 2024
1e6cd2c
chore(kleros-app): release @kleros/[email protected]
jaybuidl Nov 25, 2024
ae80adb
docs(kleros-app): readme typo
jaybuidl Nov 25, 2024
86a88bc
chore(kleros-app): release @kleros/[email protected]
jaybuidl Nov 25, 2024
42eb3ed
Merge branch 'dev' into feat/kleros-app
kemuru Nov 26, 2024
a8e6746
fix: downgrade-styled-components
Harman-singh-waraich Nov 26, 2024
ee802df
chore: update-graphql-codegen-client-preset
Harman-singh-waraich Nov 26, 2024
2f3a8d8
Merge branch 'dev' into feat/kleros-app
alcercu Nov 27, 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
3 changes: 1 addition & 2 deletions bot-pinner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"description": "Pinning of the court data to decentralized storage.",
"author": "Kleros",
"license": "MIT",
"packageManager": "[email protected]+sha256.825003a0f561ad09a3b1ac4a3b3ea6207af2796d54f62a9420520915721f5186",
"volta": {
"node": "20.11.0"
},
Expand All @@ -19,6 +18,6 @@
"node": ">=16.13.0"
},
"devDependencies": {
"@dappnode/dappnodesdk": "^0.3.11"
"@dappnode/dappnodesdk": "^0.3.35"
}
}
27 changes: 15 additions & 12 deletions contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"description": "Smart contracts for Kleros version 2",
"main": "typechain-types/index.ts",
"repository": "[email protected]:kleros/kleros-v2.git",
"homepage": "https://github.com/kleros/kleros-v2/tree/master/contracts#readme",
"author": "Kleros",
"license": "MIT",
"packageManager": "[email protected]+sha256.825003a0f561ad09a3b1ac4a3b3ea6207af2796d54f62a9420520915721f5186",
"engines": {
"node": ">=16.0.0"
},
Expand Down Expand Up @@ -60,7 +60,7 @@
"build:types": "tsc --project tsconfig.json --module esnext --declarationDir ./dist/types --emitDeclarationOnly --declaration --declarationMap"
},
"devDependencies": {
"@defi-wonderland/natspec-smells": "^1.0.3",
"@defi-wonderland/natspec-smells": "^1.1.5",
"@kleros/kleros-v2-eslint-config": "workspace:^",
"@kleros/kleros-v2-prettier-config": "workspace:^",
"@kleros/kleros-v2-tsconfig": "workspace:^",
Expand All @@ -71,18 +71,19 @@
"@openzeppelin/contracts": "^5.1.0",
"@typechain/ethers-v6": "^0.5.1",
"@typechain/hardhat": "^9.1.0",
"@types/chai": "^4.3.11",
"@types/mocha": "^10.0.6",
"@types/node": "^20.17.1",
"@wagmi/cli": "^2.1.16",
"@types/chai": "^4.3.20",
"@types/mocha": "^10.0.10",
"@types/node": "^20.17.6",
"@wagmi/cli": "^2.1.18",
"abitype": "^0.10.3",
"chai": "^4.4.1",
"dotenv": "^16.3.1",
"chai": "^4.5.0",
"dotenv": "^16.4.5",
"eslint": "^9.15.0",
"ethereumjs-util": "^7.1.5",
"ethers": "^6.13.4",
"graphql": "^16.9.0",
"graphql-request": "^6.1.0",
"hardhat": "2.22.15",
"graphql-request": "^7.1.2",
"hardhat": "2.22.16",
"hardhat-contract-sizer": "^2.10.0",
"hardhat-deploy": "^0.14.0",
"hardhat-deploy-ethers": "^0.4.2",
Expand All @@ -94,15 +95,17 @@
"node-fetch": "^3.3.2",
"pino": "^8.21.0",
"pino-pretty": "^10.3.1",
"prettier": "^3.3.3",
"prettier-plugin-solidity": "^1.4.1",
"shelljs": "^0.8.5",
"solhint-plugin-prettier": "^0.1.0",
"solidity-coverage": "^0.8.13",
"ts-node": "^10.9.2",
"typechain": "^8.3.2",
"typescript": "^5.3.3"
"typescript": "^5.6.3"
},
"dependencies": {
"@kleros/vea-contracts": "^0.4.0",
"viem": "^2.21.35"
"viem": "^2.21.48"
}
}
23 changes: 12 additions & 11 deletions eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,26 @@
"main": ".eslintrc.js",
"license": "MIT",
"dependencies": {
"@typescript-eslint/eslint-plugin": "^8.8.1",
"@typescript-eslint/parser": "^8.8.1",
"@typescript-eslint/utils": "^8.8.1",
"@typescript-eslint/eslint-plugin": "^8.15.0",
"@typescript-eslint/parser": "^8.15.0",
"@typescript-eslint/utils": "^8.15.0",
"eslint": "^9.15.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-promise": "^6.6.0",
"eslint-plugin-security": "^3.0.1",
"eslint-utils": "^3.0.0"
"eslint-utils": "^3.0.0",
"prettier": "^3.3.3"
},
"devDependencies": {
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.12.0",
"globals": "^15.11.0",
"typescript": "^5.3.3"
"@eslint/eslintrc": "^3.2.0",
"@eslint/js": "^9.15.0",
"globals": "^15.12.0",
"typescript": "^5.6.3"
},
"peerDependencies": {
"eslint": "8.x"
"eslint": "^8.0.0 || ^9.0.0"
}
}
112 changes: 112 additions & 0 deletions kleros-app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# Kleros App

Library for Kleros DApps with reusable abstractions and components.

# Usage

```node
yarn install @kleros/kleros-app
```

## 1. Atlas Interaction

- This library exports utilities to interact with Atlas (Kleros' backend) with minimal code.

- AtlasProvider : Provides functions to interact with Atlas.

> AtlasProvider needs to be wrapped with [<WagmiProvider/>](https://wagmi.sh/react/api/WagmiProvider) and [<QueryClientProvider/>](https://tanstack.com/query/latest/docs/framework/react/reference/QueryClientProvider#queryclientprovider) to work properly.

#### Usage

1. At the root of your app, setup AtlasProvider.
**uri** : Atlas backend uri
**product** : The product / Kleros DApp interacting with Atlas (CourtV2, Curate, etc.)

```typescript
import { WagmiProvider } from 'wagmi'
import { config } from './config'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { AtlasProvider, Products } from "@kleros/kleros-app";

const queryClient = new QueryClient()

function App() {
return
<WagmiProvider config={config}>
<QueryClientProvider client={queryClient}>
<AtlasProvider config={{ uri: import.meta.env.REACT_APP_ATLAS_URI, product: Products.CourtV2 }}>
...
</AtlasProvider>
</QueryClientProvider>
</WagmiProvider>
}
```

2. Once Provider is set up, use the functions provided.

```typescript
import React, { useCallback } from "react";

import { useAccount } from "wagmi";
import { useAtlasProvider } from "@kleros/kleros-app";
import { Button } from "@kleros/ui-components-library";


interface IEnsureAuth {
children: React.ReactElement;
className?: string;
}

const EnsureAuth: React.FC<IEnsureAuth> = ({ children, className }) => {
const { address } = useAccount();
const { isVerified, isSigningIn, authoriseUser } = useAtlasProvider();

const handleClick = useCallback(() => {
// authorise a user
authoriseUser()
.then((res) => { console.log(res)})
.catch((err) => {
console.log(err);
});
}, [authoriseUser]);

return isVerified ? (
children
) : (
<Button
text="Sign In"
onClick={handleClick}
disabled={isSigningIn || !address}
isLoading={isSigningIn}
{...{ className }}
/>
);
};

export default EnsureAuth;

```

3. [IAtlasProvider](https://github.com/kleros/kleros-v2/blob/feat/kleros-app/kleros-app/src/lib/atlas/providers/AtlasProvider.tsx)

```typescript
interface IAtlasProvider {
isVerified: boolean;
isSigningIn: boolean;
isAddingUser: boolean;
isFetchingUser: boolean;
isUpdatingUser: boolean;
isUploadingFile: boolean;
user: User | undefined;
userExists: boolean;
authoriseUser: () => Promise<void>;
addUser: (userSettings: AddUserData) => Promise<boolean>;
updateEmail: (userSettings: UpdateEmailData) => Promise<boolean>;
uploadFile: (file: File, role: Roles) => Promise<string | null>;
confirmEmail: (userSettings: ConfirmEmailData) => Promise<
ConfirmEmailResponse & {
isError: boolean;
}
>;
}
```
120 changes: 120 additions & 0 deletions kleros-app/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
import { fixupConfigRules, fixupPluginRules } from "@eslint/compat";
import react from "eslint-plugin-react";
import reactHooks from "eslint-plugin-react-hooks";
import security from "eslint-plugin-security";
import _import from "eslint-plugin-import";
import globals from "globals";
import tsParser from "@typescript-eslint/parser";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

export default [
{
ignores: ["src/assets"],
},
...fixupConfigRules(
compat.extends(
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"plugin:import/recommended",
"plugin:import/react",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended",
"prettier"
)
),
{
plugins: {
react: fixupPluginRules(react),
"react-hooks": fixupPluginRules(reactHooks),
security: fixupPluginRules(security),
import: fixupPluginRules(_import),
},

languageOptions: {
globals: {
...globals.browser,
...globals.node,
Atomics: "readonly",
SharedArrayBuffer: "readonly",
},

parser: tsParser,
ecmaVersion: 2020,
sourceType: "module",

parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
},

settings: {
react: {
version: "^18.3.1",
},

"import/resolver": {
typescript: {
project: "./tsconfig.json",
},
},
},

rules: {
"max-len": [
"warn",
{
code: 120,
},
],

"react/prop-types": 0,
"no-unused-vars": "off",

"@typescript-eslint/no-unused-vars": [
"error",
{
varsIgnorePattern: "(^_+[0-9]*$)|([iI]gnored$)|(^ignored)",
argsIgnorePattern: "(^_+[0-9]*$)|([iI]gnored$)|(^ignored)",
},
],

"no-console": [
"error",
{
allow: ["warn", "error", "info", "debug"],
},
],

"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-explicit-any": "off",
"security/detect-object-injection": "off",
"security/detect-non-literal-fs-filename": "off",

"import/extensions": [
"error",
"ignorePackages",
{
js: "never",
jsx: "never",
ts: "never",
tsx: "never",
},
],

"import/no-unresolved": "off",
},
},
];
Loading