Skip to content

Commit

Permalink
Merge commit 'dbfc5a6d38cd2b70a3c7e2206619b445e6f63b45' into feat/link
Browse files Browse the repository at this point in the history
# Conflicts:
#	daostar-website/src/components/Homepage/MemberLogos/MemberLogos.js
  • Loading branch information
crazyyuan committed Sep 26, 2023
2 parents ce91c25 + dbfc5a6 commit b3431eb
Show file tree
Hide file tree
Showing 1,358 changed files with 88,727 additions and 8,922 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
url = https://github.com/openzeppelin/openzeppelin-contracts
[submodule "contracts/lib/openzeppelin-contracts"]
path = contracts/lib/openzeppelin-contracts
url = https://github.com/openzeppelin/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
16 changes: 13 additions & 3 deletions DAOIPs/daoip-3.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,24 @@ The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL

### For DAOs: attestationIssuers and issuerURI

All DAOs conforming to DAOIP-3 MUST implement the `attestationIssuers` field as part of `daoURI`. `attestationIssuers`is an array of attestation endpoints (see “Attestation Endpoints”, below) hosted by service providers trusted by the DAO to issue attestations on their behalf.
All DAOs conforming to DAOIP-3 MUST implement the `attestationIssuersURI` field as part of `daoURI`.

```json
{
"@context": "<http://www.daostar.org/schemas>",
"type": "DAO",
"name": "<name of the DAO>",
"description": "<description>",
"attestationIssuersURI": "<URI>"
}
```

`attestationIssuersURI` MUST then return an array of attestation endpoints following the Attestation Issuers JSON-LD Schema below. The various issuerURIs MAY then be crawled and indexed by explorers and other services. Each issuerURI SHOULD be hosted by a service provider trusted by the DAO to issue relevant attestations on its behalf and/or on behalf of its members.

The Attestation Issuers JSON-LD Schema
```json
{
"@context": "<http://www.daostar.org/schemas>",
"type": "attestationIssuers",
"name": "Name of the DAO",
"attestationIssuers": [
{
"type": "AttestationIssuer",
Expand Down
19 changes: 19 additions & 0 deletions Implementations/API/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,25 @@ Currently supported DAOs and frameworks:

It can be forked to support other DAO frameworks.

## Build and Deployment Instructions

- Create your access key with CLI use case
Example link: https://us-east-1.console.aws.amazon.com/iamv2/home#/users/details/rashmi@daostar.org?section=security_credentials

- Open Terminal and navigate to .aws/credentails file And update the credentials
- Next, navigate to DAOStar/daostar/Implementations/API

Run the below commands

``` npm run install```
```npm run build```

Type in the stage name prod

```npm run deploy```


- Navigate to CloudFormation and View Stacks, you should see the status of prod-rest-api-Mystack

## Moloch

Expand Down
77 changes: 77 additions & 0 deletions Implementations/API/backend/functions/boardroom/getMembers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { APIGatewayProxyHandlerV2 } from "aws-lambda";
import { BoardroomKey, boardroomApiConfig } from "../config";
import fetch, { RequestInit } from "node-fetch";
import { utils } from "ethers";

function apiRequest(path: string, method: "GET" | "POST", data?: any) {
const payload: RequestInit = {
headers: {
"Content-Type": "application/json",
},
method,
redirect: "follow",
};
if (method === "POST") payload.body = JSON.stringify(data);
return fetch(path, payload).then((res) => res.json());
}

export const handler: APIGatewayProxyHandlerV2 = async (event) => {
const network = event?.pathParameters?.network;
if (!network) return { statusCode: 400, message: "Missing network" };

const path = boardroomApiConfig[network];
if (!path) return { statusCode: 400, message: "Missing config for network" };

const name = event?.pathParameters?.id;
if (!name) return { statusCode: 400, message: "Missing name" };

const cursor: string | undefined = event?.queryStringParameters?.cursor;

const template = {
"@context": {
"@vocab": "http://daostar.org/",
},
type: "DAO",
name: name,
};

let queryPath =
path +
"/" +
name +
"/voters" +
"?limit=50&key=" +
process.env.BOARDROOM_KEY;
if (cursor) {
queryPath += "&cursor=" + decodeURIComponent(cursor);
}

const res = (await apiRequest(queryPath, "GET")) as any;

if (!res.data) return { statusCode: 404, message: "DAO not found" };
const voters = res.data;
const nextCursor = res.nextCursor;

const membersFormatted = voters.map((a: any) => {
return {
id: a.address,
type: "EthereumAddress",
};
});

const transformed = {
members: membersFormatted,
...template,
nextCursor: encodeURIComponent(nextCursor),
};

return transformed
? {
statusCode: 200,
body: JSON.stringify(transformed),
}
: {
statusCode: 404,
body: JSON.stringify({ error: true }),
};
};
60 changes: 42 additions & 18 deletions Implementations/API/backend/functions/config.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,55 @@
export const daohausGraphConfig: { [key: string]: any } = {
'1': 'https://api.thegraph.com/subgraphs/name/odyssy-automaton/daohaus',
'100': 'https://api.thegraph.com/subgraphs/name/odyssy-automaton/daohaus-xdai',
'4': 'https://api.thegraph.com/subgraphs/name/odyssy-automaton/daohaus-rinkeby',
'10': 'https://api.thegraph.com/subgraphs/name/odyssy-automaton/daohaus-optimism',
}
"1": "https://api.thegraph.com/subgraphs/name/odyssy-automaton/daohaus",
"100":
"https://api.thegraph.com/subgraphs/name/odyssy-automaton/daohaus-xdai",
"4": "https://api.thegraph.com/subgraphs/name/odyssy-automaton/daohaus-rinkeby",
"10": "https://api.thegraph.com/subgraphs/name/odyssy-automaton/daohaus-optimism",
};

export const daostackGraphConfig: { [key: string]: any } = {
'1': 'https://api.thegraph.com/subgraphs/name/daostack/v41_11',
'100': 'https://api.thegraph.com/subgraphs/name/daostack/v41_11_xdai',
}
"1": "https://api.thegraph.com/subgraphs/name/daostack/v41_11",
"100": "https://api.thegraph.com/subgraphs/name/daostack/v41_11_xdai",
};

export const aaveGraphConfig: { [key: string]: any } = {
'1': 'https://api.thegraph.com/subgraphs/name/aave/governance-v2',
}
"1": "https://api.thegraph.com/subgraphs/name/aave/governance-v2",
};

export const gnosisGraphConfig: { [key: string]: any } = {
'1': 'https://api.thegraph.com/subgraphs/name/gjeanmart/gnosis-safe-mainnet'
}
"1": "https://api.thegraph.com/subgraphs/name/gjeanmart/gnosis-safe-mainnet",
};

export const gnosisApiConfig: { [key: string]: any } = {
'1': 'https://safe-transaction-mainnet.safe.global/api/v1'
}
"1": "https://safe-transaction-mainnet.safe.global/api/v1",
};

export const snapshotApiConfig: { [key: string]: any } = {
'1': 'https://hub.snapshot.org/graphql'
}
"1": "https://hub.snapshot.org/graphql",
"10": "https://hub.snapshot.org/graphql",
};

export const nonusApiConfig: { [key: string]: any } = {
'1': 'https://api.thegraph.com/subgraphs/name/nounsdao/nouns-subgraph'
}
"1": "https://api.thegraph.com/subgraphs/name/nounsdao/nouns-subgraph",
};

export const boardroomApiConfig: { [key: string]: any } = {
"1": "https://api.boardroom.info/v1/protocols",
"10": "https://api.boardroom.info/v1/protocols",
};

export const BoardroomKey = "8f123cfd353883b4f1a16db3110a69d7";

export const delegationsSubgraphs: { [key: string]: string } = {
"1": "https://subgrapher.snapshot.org/gateway.thegraph.com/api/0f15b42bdeff7a063a4e1757d7e2f99e/deployments/id/QmXZiV6S13ha6QXq4dmaM3TB4CHcDxBMvGexSNu9Kc28EH",
"5": "https://subgrapher.snapshot.org/api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-goerli",
"10": "https://subgrapher.snapshot.org/api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-optimism",
"56": "https://subgrapher.snapshot.org/api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-binance-smart-chain",
"100":
"https://subgrapher.snapshot.org/api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-gnosis-chain",
"137":
"https://subgrapher.snapshot.org/api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-polygon",
"250":
"https://subgrapher.snapshot.org/api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-fantom",
"42161":
"https://subgrapher.snapshot.org/api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-arbitrum",
};
6 changes: 3 additions & 3 deletions Implementations/API/backend/functions/gnosis/getProposals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const handler: APIGatewayProxyHandlerV2 = async (event) => {

const eventId = event?.pathParameters?.id
if (!eventId) return { statusCode: 400 }

console.log({eventId})

const checksummedId = ethers.utils.getAddress(eventId)
Expand All @@ -40,8 +40,8 @@ export const handler: APIGatewayProxyHandlerV2 = async (event) => {
name: eventId,
}

const queryPath = path + '/safes/' + checksummedId + '/multisig-transactions/?executed=false'
const queryPath = path + '/safes/' + checksummedId + '/multisig-transactions/'

console.log({queryPath})

const res = (await apiRequest(queryPath, 'GET')) as any
Expand Down
91 changes: 91 additions & 0 deletions Implementations/API/backend/functions/snapshot/getDelegations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import { APIGatewayProxyHandlerV2 } from 'aws-lambda'
import { delegationsSubgraphs } from 'functions/config'
import snapshot from '@snapshot-labs/snapshot.js';
import { getAddress } from '@ethersproject/address';


const {
subgraphRequest,
} = snapshot.utils;

async function getDelegationsOutAndIn(
network: string,
space: string
): Promise<string[]> {
if (!delegationsSubgraphs[network]) return [];

const max = 1000;
let result: any = [];
let page = 0;

const members: string[] = []

const query = {
delegations: {
__args: {
first: max,
skip: 0,
where: {
space_in: [space],
}
},
delegator: true,
delegate: true,
space: true
}
};
while (true) {
query.delegations.__args.skip = page * max;
const pageResult = await subgraphRequest(delegationsSubgraphs[network], query);
const pageDelegations = pageResult.delegations || [];
result = result.concat(pageDelegations);
page++;
if (pageDelegations.length < max) break;
}

result.forEach((delegation: any) => {
const delegator = getAddress(delegation.delegator);
const delegate = getAddress(delegation.delegate);
if (delegation.space === space) {
members.push(delegator)
members.push(delegate)

}
});

return members
}

export const handler: APIGatewayProxyHandlerV2 = async (event) => {

const space = event?.pathParameters?.id
if (!space) return { statusCode: 400, message: 'Missing id' }

const template = {
'@context': {
'@vocab': 'http://daostar.org/',
},
type: 'DAO',
name: space,
}

const members = await getDelegationsOutAndIn('1', space)

console.log({ members })

const membersFormatted = members.map((m: string) => {
return { id: m, type: 'EthereumAddress' }
})

const transformed = { members: membersFormatted, ...template }

return transformed
? {
statusCode: 200,
body: JSON.stringify(transformed),
}
: {
statusCode: 404,
body: JSON.stringify({ error: true }),
}
}
Loading

0 comments on commit b3431eb

Please sign in to comment.