From a18451e2a4b839def52267da9d1785a3dfc5af33 Mon Sep 17 00:00:00 2001
From: Han <56923450+waddaboo@users.noreply.github.com>
Date: Thu, 10 Oct 2024 15:39:08 +0800
Subject: [PATCH 01/10] feat(api): add create easAttestation credential group
to api
---
.../app/credentials/credentials.service.ts | 60 +++++++++++++------
1 file changed, 42 insertions(+), 18 deletions(-)
diff --git a/apps/api/src/app/credentials/credentials.service.ts b/apps/api/src/app/credentials/credentials.service.ts
index 268cfd53..4e36ac89 100644
--- a/apps/api/src/app/credentials/credentials.service.ts
+++ b/apps/api/src/app/credentials/credentials.service.ts
@@ -6,7 +6,9 @@ import {
Web2Provider,
providers,
Web2Context,
- BlockchainContext
+ BlockchainContext,
+ EASContext,
+ EASNetworks
} from "@bandada/credentials"
import { blockchainCredentialSupportedNetworks } from "@bandada/utils"
import { id } from "@ethersproject/hash"
@@ -139,7 +141,7 @@ export class CredentialsService {
} = this.oAuthState.get(credentialOAuthState))
const provider = getProvider(providerName)
- let context: Web2Context | BlockchainContext
+ let context: Web2Context | BlockchainContext | EASContext
if (address && credentialProvider === "blockchain") {
const { network } = credentials.credentials[i].criteria
@@ -171,6 +173,14 @@ export class CredentialsService {
jsonRpcProvider
}
+ // Check if the same account has already joined the group.
+ accountHash = id(address + groupId)
+ } else if (address && credentialProvider === "eas") {
+ context = {
+ network: EASNetworks.ETHEREUM_SEPOLIA,
+ address: address[0]
+ }
+
// Check if the same account has already joined the group.
accountHash = id(address + groupId)
} else {
@@ -259,30 +269,44 @@ export class CredentialsService {
let accountHash: string
- let context: Web2Context | BlockchainContext
+ let context: Web2Context | BlockchainContext | EASContext
if (address) {
- const { network } = JSON.parse(group.credentials).criteria
+ const { network, minAttestations } = JSON.parse(
+ group.credentials
+ ).criteria
+
+ if (network) {
+ const supportedNetwork =
+ blockchainCredentialSupportedNetworks.find(
+ (n) => n.name.toLowerCase() === network.toLowerCase()
+ )
- const supportedNetwork = blockchainCredentialSupportedNetworks.find(
- (n) => n.name.toLowerCase() === network.toLowerCase()
- )
+ if (supportedNetwork === undefined)
+ throw new BadRequestException(
+ `The network is not supported`
+ )
- if (supportedNetwork === undefined)
- throw new BadRequestException(`The network is not supported`)
+ const networkEnvVariableName = supportedNetwork.id.toUpperCase()
- const networkEnvVariableName = supportedNetwork.id.toUpperCase()
+ const web3providerRpcURL =
+ process.env[`${networkEnvVariableName}_RPC_URL`]
- const web3providerRpcURL =
- process.env[`${networkEnvVariableName}_RPC_URL`]
+ const jsonRpcProvider = await (
+ provider as BlockchainProvider
+ ).getJsonRpcProvider(web3providerRpcURL)
- const jsonRpcProvider = await (
- provider as BlockchainProvider
- ).getJsonRpcProvider(web3providerRpcURL)
+ context = {
+ address: address[0],
+ jsonRpcProvider
+ }
+ }
- context = {
- address: address[0],
- jsonRpcProvider
+ if (minAttestations) {
+ context = {
+ network: EASNetworks.ETHEREUM_SEPOLIA,
+ address: address[0]
+ }
}
// Check if the same account has already joined the group.
From 91bcd2605333abac07df0b6c35d2c69e4b116950 Mon Sep 17 00:00:00 2001
From: Han <56923450+waddaboo@users.noreply.github.com>
Date: Thu, 10 Oct 2024 15:40:08 +0800
Subject: [PATCH 02/10] feat(dashboard): add create easAttestation credential
group to dashboard
---
apps/dashboard/src/pages/credentials.tsx | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/apps/dashboard/src/pages/credentials.tsx b/apps/dashboard/src/pages/credentials.tsx
index ad79ebfb..6926fe08 100644
--- a/apps/dashboard/src/pages/credentials.tsx
+++ b/apps/dashboard/src/pages/credentials.tsx
@@ -3,7 +3,8 @@ import {
blockchain,
Web2Provider,
twitter,
- github
+ github,
+ eas
} from "@bandada/credentials"
import { Flex, Text, Button } from "@chakra-ui/react"
import { useEffect, useState, useCallback, useContext } from "react"
@@ -175,9 +176,10 @@ export default function CredentialsPage() {
clientRedirectUri
)
- // If the credential is blockchain
+ // If the credential is blockchain or eas attestations
if (
- providerName === blockchain.name &&
+ (providerName === blockchain.name ||
+ providerName === eas.name) &&
isLoggedInAdmin() &&
state
) {
From 528efbf9d98918cbb3f6a7837355291defe56a9f Mon Sep 17 00:00:00 2001
From: Han <56923450+waddaboo@users.noreply.github.com>
Date: Thu, 10 Oct 2024 15:39:08 +0800
Subject: [PATCH 03/10] feat(api): add create easAttestation credential group
to api
---
.../app/credentials/credentials.service.ts | 60 +++++++++++++------
1 file changed, 42 insertions(+), 18 deletions(-)
diff --git a/apps/api/src/app/credentials/credentials.service.ts b/apps/api/src/app/credentials/credentials.service.ts
index 268cfd53..4e36ac89 100644
--- a/apps/api/src/app/credentials/credentials.service.ts
+++ b/apps/api/src/app/credentials/credentials.service.ts
@@ -6,7 +6,9 @@ import {
Web2Provider,
providers,
Web2Context,
- BlockchainContext
+ BlockchainContext,
+ EASContext,
+ EASNetworks
} from "@bandada/credentials"
import { blockchainCredentialSupportedNetworks } from "@bandada/utils"
import { id } from "@ethersproject/hash"
@@ -139,7 +141,7 @@ export class CredentialsService {
} = this.oAuthState.get(credentialOAuthState))
const provider = getProvider(providerName)
- let context: Web2Context | BlockchainContext
+ let context: Web2Context | BlockchainContext | EASContext
if (address && credentialProvider === "blockchain") {
const { network } = credentials.credentials[i].criteria
@@ -171,6 +173,14 @@ export class CredentialsService {
jsonRpcProvider
}
+ // Check if the same account has already joined the group.
+ accountHash = id(address + groupId)
+ } else if (address && credentialProvider === "eas") {
+ context = {
+ network: EASNetworks.ETHEREUM_SEPOLIA,
+ address: address[0]
+ }
+
// Check if the same account has already joined the group.
accountHash = id(address + groupId)
} else {
@@ -259,30 +269,44 @@ export class CredentialsService {
let accountHash: string
- let context: Web2Context | BlockchainContext
+ let context: Web2Context | BlockchainContext | EASContext
if (address) {
- const { network } = JSON.parse(group.credentials).criteria
+ const { network, minAttestations } = JSON.parse(
+ group.credentials
+ ).criteria
+
+ if (network) {
+ const supportedNetwork =
+ blockchainCredentialSupportedNetworks.find(
+ (n) => n.name.toLowerCase() === network.toLowerCase()
+ )
- const supportedNetwork = blockchainCredentialSupportedNetworks.find(
- (n) => n.name.toLowerCase() === network.toLowerCase()
- )
+ if (supportedNetwork === undefined)
+ throw new BadRequestException(
+ `The network is not supported`
+ )
- if (supportedNetwork === undefined)
- throw new BadRequestException(`The network is not supported`)
+ const networkEnvVariableName = supportedNetwork.id.toUpperCase()
- const networkEnvVariableName = supportedNetwork.id.toUpperCase()
+ const web3providerRpcURL =
+ process.env[`${networkEnvVariableName}_RPC_URL`]
- const web3providerRpcURL =
- process.env[`${networkEnvVariableName}_RPC_URL`]
+ const jsonRpcProvider = await (
+ provider as BlockchainProvider
+ ).getJsonRpcProvider(web3providerRpcURL)
- const jsonRpcProvider = await (
- provider as BlockchainProvider
- ).getJsonRpcProvider(web3providerRpcURL)
+ context = {
+ address: address[0],
+ jsonRpcProvider
+ }
+ }
- context = {
- address: address[0],
- jsonRpcProvider
+ if (minAttestations) {
+ context = {
+ network: EASNetworks.ETHEREUM_SEPOLIA,
+ address: address[0]
+ }
}
// Check if the same account has already joined the group.
From f833996a160154fb5edeed176f161612a9f72daa Mon Sep 17 00:00:00 2001
From: Han <56923450+waddaboo@users.noreply.github.com>
Date: Thu, 10 Oct 2024 15:40:08 +0800
Subject: [PATCH 04/10] feat(dashboard): add create easAttestation credential
group to dashboard
---
apps/dashboard/src/pages/credentials.tsx | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/apps/dashboard/src/pages/credentials.tsx b/apps/dashboard/src/pages/credentials.tsx
index ad79ebfb..6926fe08 100644
--- a/apps/dashboard/src/pages/credentials.tsx
+++ b/apps/dashboard/src/pages/credentials.tsx
@@ -3,7 +3,8 @@ import {
blockchain,
Web2Provider,
twitter,
- github
+ github,
+ eas
} from "@bandada/credentials"
import { Flex, Text, Button } from "@chakra-ui/react"
import { useEffect, useState, useCallback, useContext } from "react"
@@ -175,9 +176,10 @@ export default function CredentialsPage() {
clientRedirectUri
)
- // If the credential is blockchain
+ // If the credential is blockchain or eas attestations
if (
- providerName === blockchain.name &&
+ (providerName === blockchain.name ||
+ providerName === eas.name) &&
isLoggedInAdmin() &&
state
) {
From 131ade46ffe29e3136369a3a2af30686e384b21a Mon Sep 17 00:00:00 2001
From: Han <56923450+waddaboo@users.noreply.github.com>
Date: Thu, 10 Oct 2024 21:23:53 +0800
Subject: [PATCH 05/10] feat(dashboard): add EAS network list dropdown
---
apps/api/src/app/credentials/credentials.service.ts | 9 +++------
.../new-group-stepper/access-mode-step.tsx | 12 ++++++++++--
2 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/apps/api/src/app/credentials/credentials.service.ts b/apps/api/src/app/credentials/credentials.service.ts
index 4e36ac89..f33ca565 100644
--- a/apps/api/src/app/credentials/credentials.service.ts
+++ b/apps/api/src/app/credentials/credentials.service.ts
@@ -7,8 +7,7 @@ import {
providers,
Web2Context,
BlockchainContext,
- EASContext,
- EASNetworks
+ EASContext
} from "@bandada/credentials"
import { blockchainCredentialSupportedNetworks } from "@bandada/utils"
import { id } from "@ethersproject/hash"
@@ -177,7 +176,6 @@ export class CredentialsService {
accountHash = id(address + groupId)
} else if (address && credentialProvider === "eas") {
context = {
- network: EASNetworks.ETHEREUM_SEPOLIA,
address: address[0]
}
@@ -276,7 +274,7 @@ export class CredentialsService {
group.credentials
).criteria
- if (network) {
+ if (network && !minAttestations) {
const supportedNetwork =
blockchainCredentialSupportedNetworks.find(
(n) => n.name.toLowerCase() === network.toLowerCase()
@@ -302,9 +300,8 @@ export class CredentialsService {
}
}
- if (minAttestations) {
+ if (network && minAttestations) {
context = {
- network: EASNetworks.ETHEREUM_SEPOLIA,
address: address[0]
}
}
diff --git a/apps/dashboard/src/components/new-group-stepper/access-mode-step.tsx b/apps/dashboard/src/components/new-group-stepper/access-mode-step.tsx
index 55f39420..cca026d5 100644
--- a/apps/dashboard/src/components/new-group-stepper/access-mode-step.tsx
+++ b/apps/dashboard/src/components/new-group-stepper/access-mode-step.tsx
@@ -1,5 +1,5 @@
import { validators } from "@bandada/credentials"
-import { blockchainCredentialSupportedNetworks } from "@bandada/utils"
+import { blockchainCredentialSupportedNetworks, easCredentialSupportedNetworks } from "@bandada/utils"
import {
Box,
Button,
@@ -254,7 +254,15 @@ export default function AccessModeStep({
})
}
>
- {blockchainCredentialSupportedNetworks.map(
+ {validators[_validator].criteriaABI.minAttestations ? easCredentialSupportedNetworks.map(
+ (network: any) => (
+
+ )
+ ) : blockchainCredentialSupportedNetworks.map(
(network: any) => (
+ )
+ ) : blockchainCredentialSupportedNetworks.map(
(network: any) => (
- )
- ) : blockchainCredentialSupportedNetworks.map(
- (network: any) => (
-
- )
- )}
+ {validators[_validator]
+ .criteriaABI.minAttestations
+ ? easCredentialSupportedNetworks.map(
+ (network: any) => (
+
+ )
+ )
+ : blockchainCredentialSupportedNetworks.map(
+ (network: any) => (
+
+ )
+ )}
)}
{parameter[1].type === "boolean" && (
From 9863009c4ca6f8a6ad0e757b6838ffaa305b604b Mon Sep 17 00:00:00 2001
From: Han <56923450+waddaboo@users.noreply.github.com>
Date: Fri, 11 Oct 2024 15:07:21 +0800
Subject: [PATCH 10/10] refactor(api): update to check blockchain type instead
of not eas check
---
apps/api/src/app/credentials/credentials.service.ts | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/apps/api/src/app/credentials/credentials.service.ts b/apps/api/src/app/credentials/credentials.service.ts
index f33ca565..deb91cf4 100644
--- a/apps/api/src/app/credentials/credentials.service.ts
+++ b/apps/api/src/app/credentials/credentials.service.ts
@@ -270,11 +270,10 @@ export class CredentialsService {
let context: Web2Context | BlockchainContext | EASContext
if (address) {
- const { network, minAttestations } = JSON.parse(
- group.credentials
- ).criteria
+ const { network, minBalance, minTransactions, minAttestations } =
+ JSON.parse(group.credentials).criteria
- if (network && !minAttestations) {
+ if (network && (minBalance || minTransactions)) {
const supportedNetwork =
blockchainCredentialSupportedNetworks.find(
(n) => n.name.toLowerCase() === network.toLowerCase()