diff --git a/README.md b/README.md index 14790fbb..dc06ad1c 100644 --- a/README.md +++ b/README.md @@ -1,54 +1,39 @@ # Tezos Homebase + [![](https://img.shields.io/badge/license-MIT-brightgreen)](LICENSE) Homebase is a platform designed to let users create and manage DAOs on the Tezos blockchain. - + # Prerequisites + The following dependencies are required to run homebase-app: | Dependency | Version | | ---------- | ------------------- | -| Node | `v12.18.4` or above | +| Node | `v16.16.0` or above | | Yarn | `v1.22.*` or above | # Third Party Services The following third party services are being used by Homebase: -## [Better Call Dev API](https://better-call.dev/docs) -### Base URL: https://api.better-call.dev/v1 - -| Endpoint | URL | METHOD | -| ------------------- | -------------------------------------------------------------------- | ------ | -| BigMap Keys | /bigmap/{network}/{number}/keys | GET | -| Contract | /contract/{network}/{address} | GET | -| Contract Operations | /contract/{network}/{address}/operations?size=10000&entrypoints=vote | GET | -| Contract Storage | /contract/{network}/{address}/storage | GET | - -## [Pinata IPFS](https://pinata.cloud/) -### Base URL: https://api.pinata.cloud - -| Endpoint | URL | METHOD | -| ------------- | --------------------------- | ------ | -| Pin to IPFS | /pinning/pinJSONToIPFS | POST | -| Pin List | /data/pinList?status=pinned | GET | -| Hash Metadata | /pinning/hashMetadata | PUT | - ## [TZKT API](https://api.tzkt.io/) + ### Base URL: https://api.tzkt.io/ | Endpoint | URL | METHOD | | ---------- | ---------------------------------- | ------ | | Operations | /v1/accounts/${address}/operations | GET | +## [Taquito Beacon Wallet](https://docs.walletbeacon.io/) + +### Version: 13.0.1 -## [Airgap's Beacon SDK](https://github.com/airgap-it/beacon-sdk) -### Version: 2.2.1 # Using Homebase ## Creating a DAO -1. Go to https://tezos-homebase.netlify.app/ +1. Go to https://tezos-homebase.io/ 2. Click on the `Create a DAO` button You will be taken to the DAO Creator, from which you will be asked to choose on the currently supported DAO templates. @@ -58,25 +43,25 @@ You will be taken to the DAO Creator, from which you will be asked to choose on **DAO Settings**: - * DAO Name: this will also be the name of the DAO's token. - * Token Symbol - * Description +- DAO Name: this will also be the name of the DAO's token. +- Token Symbol +- Description **Proposals and Voting**: - * **`Voting period duration`** - * **`Required stake to propose`**: required amount of DAO tokens to stake at the time of proposing. Currently follows the formula: `b + proposalSize`. Where: - - Proposal size is autocalculated based on the amount of transfers/registry updates (will get outdated soon on the contracts side) - - B is a constant amount of tokens - * **`Returned stake after proposal rejection`** - * **`Transfer amounts`** **(Treasury only)**: maximum and minimum amounts that can be transferred in a treasury proposal transfer. Currently only supports `XTZ` - * **`Quorum threshold`**: currently a natural number representing the total amount of votes required for a proposal to pass. Each token staked in a vote operation represents a vote. Therefore, with a quorum threshold of 500, a vote that stakes 500 tokens would make the proposal pass. - * **`Maximum proposal size`** +- **`Voting period duration`** +- **`Required stake to propose`**: required amount of DAO tokens to stake at the time of proposing. Currently follows the formula: `b + proposalSize`. Where: + - Proposal size is autocalculated based on the amount of transfers/registry updates (will get outdated soon on the contracts side) + - B is a constant amount of tokens +- **`Returned stake after proposal rejection`** +- **`Transfer amounts`** **(Treasury only)**: maximum and minimum amounts that can be transferred in a treasury proposal transfer. Currently only supports `XTZ` +- **`Quorum threshold`**: currently a natural number representing the total amount of votes required for a proposal to pass. Each token staked in a vote operation represents a vote. Therefore, with a quorum threshold of 500, a vote that stakes 500 tokens would make the proposal pass. +- **`Maximum proposal size`** **Distribution Settings**: - * **`TokenHolders`**: initial token holder addresses and their initial balances. At least 1 is required. - * **`Administrator`** +- **`TokenHolders`**: initial token holder addresses and their initial balances. At least 1 is required. +- **`Administrator`** 5. You will then be taken to the review page. From here, click the `LAUNCH` button on the bottom right corner. 6. You will be redirected to the Launch screen. Do not close your browser tab until the whole process is complete (you are able to see and track progress by looking at the progress bar of this screen). You will be asked to connect your wallet if you haven't already, and then will be asked for 2 signatures: the first one originates the `Metadata Carrier` contract and the second one originates the actual `DAO contract`. When the originations are complete you will see a success message and a `Go to my DAO` button @@ -88,45 +73,48 @@ There is a searchbar available, however, note that searches done using this bar Specific DAOs can be explored by clicking on them in the home screen or by URL: -`https://tezos-homebase.herokuapp.com/explorer/dao/${DAO_ADDRESS}` +`https://tezos-homebase.io/explorer/dao/${DAO_ADDRESS}` ## Managing a DAO All DAOs, regardless of their template, have: **DAO page**: contains all general DAO information. Here you can see: - * Current cycle - * Time left to vote - * DAO name and description - * DAO template type - * Token holders and their balances - * Active proposals - * Frozen tokens - * Voting addresses - * `Execute` button + +- Current cycle +- Time left to vote +- DAO name and description +- DAO template type +- Token holders and their balances +- Active proposals +- Frozen tokens +- Voting addresses +- `Execute` button **Proposals page**: contains all proposals related information and related actions. Here you can see: - * DAO name - * `New Proposal` button and creation modal - * `Execute` button - * Active proposals - * Frozen tokens - * Voting addresses - * Tables with all proposals, passed proposals and active proposals. Each proposal item contains: - * Title - * Hash - * Creation date and cycle - * Quorum reached vs quorum threshold - * For/Against votes vs total votes + +- DAO name +- `New Proposal` button and creation modal +- `Execute` button +- Active proposals +- Frozen tokens +- Voting addresses +- Tables with all proposals, passed proposals and active proposals. Each proposal item contains: + - Title + - Hash + - Creation date and cycle + - Quorum reached vs quorum threshold + - For/Against votes vs total votes **Proposal detail page**: contains all specific information about a proposal and vote actions. Here you can see: - * Breakdown of the proposal's details (transfers to execute, registry items to update, among others) - * Proposal title and description - * Status badge and history - * Quorum reached vs quorum threshold - * Proposer - * For and against votes, each with a detailed modal - * Vote for and against buttons and modals. Only enabled if proposal is active + +- Breakdown of the proposal's details (transfers to execute, registry items to update, among others) +- Proposal title and description +- Status badge and history +- Quorum reached vs quorum threshold +- Proposer +- For and against votes, each with a detailed modal +- Vote for and against buttons and modals. Only enabled if proposal is active **Proposal creation modal**: all proposal creation modals support multiple operations batched in the same proposal and also allow the user to batch upload transactions with a JSON file. This JSON should follow a specific signature, based on the template type of the DAO. See [proposal JSON signatures for each template](#dao-template-specific-pages-and-details) @@ -179,6 +167,7 @@ At a contract level, there is no such distinction, but in the UI it exists to le ``` # Contributing + ## Developer Docs - [Tezos Homebase Docs](https://docs.google.com/document/d/1zZwcvX0jNE8PycOMNSULy2i-mcjg1LJ9FFYbGP4m9TM/edit?usp=sharing) @@ -197,8 +186,8 @@ To run the project: # Glossary -* **Execute (Flush)**: execute all passed proposals from periods previous to the last one. If the proposal is rejected or did not meet the quorum threshold, then the Execute operation removes it from the proposals list. +- **Execute (Flush)**: execute all passed proposals from periods previous to the last one. If the proposal is rejected or did not meet the quorum threshold, then the Execute operation removes it from the proposals list. -* **Administrator**: address with permissions to mint, burn and transfer tokens in the DAO without a proposal. It is configured by the DAO creator and can be another contract (like a multisig) +- **Administrator**: address with permissions to mint, burn and transfer tokens in the DAO without a proposal. It is configured by the DAO creator and can be another contract (like a multisig) -* **Proposal size**: metric that describes the size, in packed bytes, of a proposal's metadata. Therefore, the bigger the proposal arguments are (more transfers or more registry updates), the bigger the proposal size is. +- **Proposal size**: metric that describes the size, in packed bytes, of a proposal's metadata. Therefore, the bigger the proposal arguments are (more transfers or more registry updates), the bigger the proposal size is. diff --git a/src/App.tsx b/src/App.tsx index 6609c537..328a4c2e 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -103,21 +103,21 @@ const App: React.FC = () => { - + /> */} - + /> */}
diff --git a/src/modules/explorer/components/ProposalForm.tsx b/src/modules/explorer/components/ProposalForm.tsx index 97194296..dc538e84 100644 --- a/src/modules/explorer/components/ProposalForm.tsx +++ b/src/modules/explorer/components/ProposalForm.tsx @@ -125,16 +125,17 @@ export const ProposalFormContainer: React.FC = ({ open, handleClose, defa const mappedTransfers = [...values.transferForm.transfers, ...values.nftTransferForm.transfers] .filter(transfer => !!transfer.amount && !!transfer.asset && !!transfer.recipient) - .map(transfer => - (transfer.asset as Asset).symbol === "XTZ" + .map(transfer => { + const type = (transfer.asset as Token).standard === "fa2" ? "FA2" : "FA1.2" + return (transfer.asset as Asset).symbol === "XTZ" ? { ...transfer, amount: transfer.amount, type: "XTZ" as const } : { ...transfer, amount: transfer.amount, asset: transfer.asset as Token, - type: "FA2" as const + type: type } - ) + }) const mappedList = values.registryUpdateForm.list.filter(item => !!item.key && !!item.value) diff --git a/src/services/bakingBad/tokenBalances/index.ts b/src/services/bakingBad/tokenBalances/index.ts index 3e174092..55ec5c1f 100644 --- a/src/services/bakingBad/tokenBalances/index.ts +++ b/src/services/bakingBad/tokenBalances/index.ts @@ -33,7 +33,7 @@ export const getDAOBalances = async ( offset = 0, balances: DAOBalance[] = [] ): Promise => { - const url = `https://api.${networkNameMap[network]}.tzkt.io/v1/tokens/balances?account=${daoId}&limit=${ELEMENTS_PER_REQUEST}&offset=${offset}&token.metadata.artifactUri.null=true&token.standard=fa2` + const url = `https://api.${networkNameMap[network]}.tzkt.io/v1/tokens/balances?account=${daoId}&limit=${ELEMENTS_PER_REQUEST}&offset=${offset}&token.metadata.artifactUri.null=true` const response = await fetch(url) if (!response.ok) { @@ -83,7 +83,7 @@ export const getDAONFTBalances = async ( offset = 0, balances: DAOBalance[] = [] ): Promise => { - const url = `https://api.${networkNameMap[network]}.tzkt.io/v1/tokens/balances?account=${daoId}&limit=${ELEMENTS_PER_REQUEST}&offset=${offset}&token.metadata.artifactUri.null=false&token.standard=fa2` + const url = `https://api.${networkNameMap[network]}.tzkt.io/v1/tokens/balances?account=${daoId}&limit=${ELEMENTS_PER_REQUEST}&offset=${offset}&token.metadata.artifactUri.null=false` const response = await fetch(url) if (!response.ok) { diff --git a/src/services/contracts/baseDAO/lambdaDAO/michelson/supported_lambda_types/transfer_proposal_type.json b/src/services/contracts/baseDAO/lambdaDAO/michelson/supported_lambda_types/transfer_proposal_type.json index 3887df12..07c93b5f 100644 --- a/src/services/contracts/baseDAO/lambdaDAO/michelson/supported_lambda_types/transfer_proposal_type.json +++ b/src/services/contracts/baseDAO/lambdaDAO/michelson/supported_lambda_types/transfer_proposal_type.json @@ -1,137 +1,190 @@ { - "prim": "pair", - "args": [ - { - "prim": "pair", - "args": [ - { - "prim": "nat", - "annots": [ - "%agora_post_id" - ] - }, - { - "prim": "list", - "annots": [ - "%registry_diff" - ], - "args": [ - { - "prim": "pair", - "args": [ - { - "prim": "string" - }, - { - "prim": "option", - "args": [ - { - "prim": "string" - } - ] - } - ] - } - ] - } - ] - }, - { - "prim": "list", - "annots": [ - "%transfers" - ], - "args": [ - { - "prim": "or", - "args": [ - { - "prim": "pair", - "annots": [ - "%xtz_transfer_type" - ], - "args": [ - { - "prim": "mutez", - "annots": [ - "%amount" - ] - }, - { - "prim": "address", - "annots": [ - "%recipient" - ] - } - ] - }, - { - "prim": "pair", - "annots": [ - "%token_transfer_type" - ], - "args": [ - { - "prim": "address", - "annots": [ - "%contract_address" - ] - }, - { - "prim": "list", - "annots": [ - "%transfer_list" - ], - "args": [ - { - "prim": "pair", - "args": [ - { - "prim": "address", - "annots": [ - "%from_" - ] - }, - { - "prim": "list", - "annots": [ - "%txs" - ], - "args": [ - { - "prim": "pair", - "args": [ - { - "prim": "address", - "annots": [ - "%to_" - ] - }, - { - "prim": "nat", - "annots": [ - "%token_id" - ] - }, - { - "prim": "nat", - "annots": [ - "%amount" - ] - } - ] - } - ] - } - ] - } - ] - } - ] - } - ] - } - ] - } - ] - } \ No newline at end of file + "prim": "pair", + "args": [ + { + "prim": "pair", + "args": [ + { + "prim": "nat", + "annots": [ + "%agora_post_id" + ] + }, + { + "prim": "list", + "annots": [ + "%registry_diff" + ], + "args": [ + { + "prim": "pair", + "args": [ + { + "prim": "string" + }, + { + "prim": "option", + "args": [ + { + "prim": "string" + } + ] + } + ] + } + ] + } + ] + }, + { + "prim": "list", + "annots": [ + "%transfers" + ], + "args": [ + { + "prim": "or", + "args": [ + { + "prim": "pair", + "annots": [ + "%xtz_transfer_type" + ], + "args": [ + { + "prim": "mutez", + "annots": [ + "%amount" + ] + }, + { + "prim": "address", + "annots": [ + "%recipient" + ] + } + ] + }, + { + "prim": "or", + "args": [ + { + "prim": "pair", + "annots": [ + "%token_transfer_type" + ], + "args": [ + { + "prim": "address", + "annots": [ + "%contract_address" + ] + }, + { + "prim": "list", + "annots": [ + "%transfer_list" + ], + "args": [ + { + "prim": "pair", + "args": [ + { + "prim": "address", + "annots": [ + "%from_" + ] + }, + { + "prim": "list", + "annots": [ + "%txs" + ], + "args": [ + { + "prim": "pair", + "args": [ + { + "prim": "address", + "annots": [ + "%to_" + ] + }, + { + "prim": "nat", + "annots": [ + "%token_id" + ] + }, + { + "prim": "nat", + "annots": [ + "%amount" + ] + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "prim": "pair", + "annots": [ + "%legacy_token_transfer_type" + ], + "args": [ + { + "prim": "address", + "annots": [ + "%contract_address" + ] + }, + { + "prim": "pair", + "annots": [ + "%transfer" + ], + "args": [ + { + "prim": "address", + "annots": [ + "%from" + ] + }, + { + "prim": "pair", + "annots": [ + "%target" + ], + "args": [ + { + "prim": "address", + "annots": [ + "%to" + ] + }, + { + "prim": "nat", + "annots": [ + "%value" + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/services/contracts/baseDAO/lambdaDAO/types.ts b/src/services/contracts/baseDAO/lambdaDAO/types.ts index 23a2eff7..d3dfd685 100644 --- a/src/services/contracts/baseDAO/lambdaDAO/types.ts +++ b/src/services/contracts/baseDAO/lambdaDAO/types.ts @@ -365,6 +365,17 @@ export interface PMFA2TransferType { ] } +export interface PMFA12TransferType { + contract_address: string + transfer: { + from: string + target: { + to: string + value: BigNumber + } + } +} + interface ConfigProposalDTO { frozen_extra_value?: string frozen_scale_value?: string @@ -389,7 +400,7 @@ export type PMTreasuryProposal = | { transfer_proposal: { agora_post_id: string - transfers: (PMXTZTransferType | PMFA2TransferType)[] + transfers: (PMXTZTransferType | PMFA2TransferType | PMFA12TransferType)[] } } @@ -402,7 +413,7 @@ export type PMRegistryProposal = "0": string "1": string }[] - transfers: (PMXTZTransferType | PMFA2TransferType)[] + transfers: (PMXTZTransferType | PMFA2TransferType | PMFA12TransferType)[] } } diff --git a/src/services/contracts/baseDAO/types.ts b/src/services/contracts/baseDAO/types.ts index a2eb2a8d..95b426a5 100644 --- a/src/services/contracts/baseDAO/types.ts +++ b/src/services/contracts/baseDAO/types.ts @@ -12,7 +12,7 @@ export interface TokenHolder { balance: number } -export type TransferParams = XTZTransferParams | FA2TransferParams +export type TransferParams = XTZTransferParams | FA2TransferParams | FA12TransferParams export interface XTZTransferParams { amount: number @@ -23,7 +23,14 @@ export interface XTZTransferParams { export interface FA2TransferParams { amount: number recipient: string - type: "FA2" + type: string + asset: TokenModel +} + +export interface FA12TransferParams { + amount: number + recipient: string + type: string asset: TokenModel } diff --git a/src/services/indexer/dao/mappers/proposal/index.ts b/src/services/indexer/dao/mappers/proposal/index.ts index 969e4aa4..5a7185ef 100644 --- a/src/services/indexer/dao/mappers/proposal/index.ts +++ b/src/services/indexer/dao/mappers/proposal/index.ts @@ -1,10 +1,12 @@ import { Transfer } from "./types" import { formatUnits, xtzToMutez } from "services/contracts/utils" import BigNumber from "bignumber.js" -import { FA2TransferParams, TransferParams, XTZTransferParams } from "services/contracts/baseDAO" -import { PMFA2TransferType, PMXTZTransferType } from "services/contracts/baseDAO/lambdaDAO/types" +import { FA12TransferParams, FA2TransferParams, TransferParams, XTZTransferParams } from "services/contracts/baseDAO" +import { PMFA12TransferType, PMFA2TransferType, PMXTZTransferType } from "services/contracts/baseDAO/lambdaDAO/types" -export const extractTransfersData = (transfersDTO: (PMXTZTransferType | PMFA2TransferType)[]): Transfer[] => { +export const extractTransfersData = ( + transfersDTO: (PMXTZTransferType | PMFA2TransferType | PMFA12TransferType)[] +): Transfer[] => { const transfers = transfersDTO.map((transfer: any) => { if (transfer.hasOwnProperty("xtz_transfer_type")) { const xtzTransfer = transfer @@ -14,7 +16,7 @@ export const extractTransfersData = (transfersDTO: (PMXTZTransferType | PMFA2Tra beneficiary: xtzTransfer.xtz_transfer_type.recipient, type: "XTZ" as const } - } else { + } else if (transfer.hasOwnProperty("token_transfer_type")) { const fa2Transfer = transfer return { @@ -24,6 +26,17 @@ export const extractTransfersData = (transfersDTO: (PMXTZTransferType | PMFA2Tra tokenId: fa2Transfer.token_transfer_type.transfer_list[0].txs[0].token_id, type: "FA2" as const } + } else { + const fa12Transfer = transfer + console.log("fa12Transfer: ", fa12Transfer) + + return { + amount: fa12Transfer.legacy_token_transfer_type.transfer.target.value, + beneficiary: fa12Transfer.legacy_token_transfer_type.transfer.target.to, + contractAddress: fa12Transfer.legacy_token_transfer_type.contract_address, + type: "FA1.2" as const, + tokenId: "0" + } } }) @@ -59,12 +72,31 @@ const mapFA2TransfersArgs = (transfer: FA2TransferParams, daoAddress: string) => } } +const mapFA12TransfersArgs = (transfer: FA12TransferParams, daoAddress: string) => { + return { + legacy_token_transfer_type: { + contract_address: transfer.asset.contract, + transfer: { + from: daoAddress, + target: { + to: transfer.recipient, + value: formatUnits(new BigNumber(transfer.amount), transfer.asset.decimals).toNumber() + } + } + } + } +} + export const mapTransfersArgs = (transfers: TransferParams[], daoAddress: string) => { return transfers.map(transfer => { if (transfer.type === "FA2") { return mapFA2TransfersArgs(transfer, daoAddress) } - return mapXTZTransfersArgs(transfer) + if (transfer.type === "FA1.2") { + return mapFA12TransfersArgs(transfer as FA12TransferParams, daoAddress) + } + + return mapXTZTransfersArgs(transfer as XTZTransferParams) }) } diff --git a/src/services/indexer/dao/mappers/proposal/types.ts b/src/services/indexer/dao/mappers/proposal/types.ts index 17503698..e38c2a9e 100644 --- a/src/services/indexer/dao/mappers/proposal/types.ts +++ b/src/services/indexer/dao/mappers/proposal/types.ts @@ -37,7 +37,7 @@ export enum ProposalStatus { export interface Transfer { amount: BigNumber beneficiary: string - type: "XTZ" | "FA2" + type: "XTZ" | "FA2" | "FA1.2" } export interface FA2Transfer extends Transfer {