diff --git a/migrations/configs/ganache.config.ts b/migrations/configs/ganache.config.ts index 6091e9eba..97f1ec910 100644 --- a/migrations/configs/ganache.config.ts +++ b/migrations/configs/ganache.config.ts @@ -6,8 +6,6 @@ import { const disabled: Array = [ // Utility & Test Contracts disabled by default "OLToken", - "TestToken1", - "TestToken2", "TestFairShareCalc", "PixelNFT", "ProxToken", diff --git a/migrations/configs/goerli.config.ts b/migrations/configs/goerli.config.ts index 49d41d8d4..6091e9eba 100644 --- a/migrations/configs/goerli.config.ts +++ b/migrations/configs/goerli.config.ts @@ -1,6 +1,7 @@ -import { adaptersIdsMap } from "../../utils/dao-ids-util"; -import { contracts as defaultContracts } from "./contracts.config"; -import { getNetworkDetails } from "../../utils/deployment-util"; +import { + contracts as defaultContracts, + ContractConfig, +} from "./contracts.config"; const disabled: Array = [ // Utility & Test Contracts disabled by default @@ -14,22 +15,9 @@ const disabled: Array = [ "MockDao", ]; -export const contracts = defaultContracts - .map((c) => { - if (disabled.find((e) => e === c.name)) { - return { ...c, enabled: false }; - } - return c; - }) - .map((c) => { - if (adaptersIdsMap.COUPON_MANAGER_ADAPTER === c.id) { - const chainDetails = getNetworkDetails("goerli"); - return { - ...c, - deploymentArgs: { - chainId: chainDetails?.chainId, - }, - }; - } - return c; - }); +export const contracts: Array = defaultContracts.map((c) => { + if (disabled.find((e) => e === c.name)) { + return { ...c, enabled: false }; + } + return c; +}); diff --git a/migrations/configs/harmony.config.ts b/migrations/configs/harmony.config.ts index 5a2fa9e32..662e482b3 100644 --- a/migrations/configs/harmony.config.ts +++ b/migrations/configs/harmony.config.ts @@ -1,8 +1,7 @@ -import { adaptersIdsMap } from "../../utils/dao-ids-util"; import { contracts as defaultContracts, + ContractConfig, } from "./contracts.config"; -import { getNetworkDetails } from "../../utils/deployment-util"; const disabled: Array = [ // Utility & Test Contracts disabled by default @@ -22,22 +21,9 @@ const disabled: Array = [ "DistributeContract", ]; -export const contracts = defaultContracts - .map((c) => { - if (disabled.find((e) => e === c.name)) { - return { ...c, enabled: false }; - } - return c; - }) - .map((c) => { - if (adaptersIdsMap.COUPON_MANAGER_ADAPTER === c.id) { - const chainDetails = getNetworkDetails("harmony"); - return { - ...c, - deploymentArgs: { - chainId: chainDetails?.chainId, - }, - }; - } - return c; - }); +export const contracts: Array = defaultContracts.map((c) => { + if (disabled.find((e) => e === c.name)) { + return { ...c, enabled: false }; + } + return c; +}); diff --git a/migrations/configs/harmonytest.config.ts b/migrations/configs/harmonytest.config.ts index 90d0dbb57..6091e9eba 100644 --- a/migrations/configs/harmonytest.config.ts +++ b/migrations/configs/harmonytest.config.ts @@ -1,6 +1,7 @@ -import { adaptersIdsMap } from "../../utils/dao-ids-util"; -import { contracts as defaultContracts } from "./contracts.config"; -import { getNetworkDetails } from "../../utils/deployment-util"; +import { + contracts as defaultContracts, + ContractConfig, +} from "./contracts.config"; const disabled: Array = [ // Utility & Test Contracts disabled by default @@ -14,22 +15,9 @@ const disabled: Array = [ "MockDao", ]; -export const contracts = defaultContracts - .map((c) => { - if (disabled.find((e) => e === c.name)) { - return { ...c, enabled: false }; - } - return c; - }) - .map((c) => { - if (adaptersIdsMap.COUPON_MANAGER_ADAPTER === c.id) { - const chainDetails = getNetworkDetails("harmonytest"); - return { - ...c, - deploymentArgs: { - chainId: chainDetails?.chainId, - }, - }; - } - return c; - }); +export const contracts: Array = defaultContracts.map((c) => { + if (disabled.find((e) => e === c.name)) { + return { ...c, enabled: false }; + } + return c; +}); diff --git a/migrations/configs/mainnet.config.ts b/migrations/configs/mainnet.config.ts index 1e77578f7..662e482b3 100644 --- a/migrations/configs/mainnet.config.ts +++ b/migrations/configs/mainnet.config.ts @@ -1,8 +1,7 @@ -import { adaptersIdsMap } from "../../utils/dao-ids-util"; import { contracts as defaultContracts, + ContractConfig, } from "./contracts.config"; -import { getNetworkDetails } from "../../utils/deployment-util"; const disabled: Array = [ // Utility & Test Contracts disabled by default @@ -22,22 +21,9 @@ const disabled: Array = [ "DistributeContract", ]; -export const contracts = defaultContracts - .map((c) => { - if (disabled.find((e) => e === c.name)) { - return { ...c, enabled: false }; - } - return c; - }) - .map((c) => { - if (adaptersIdsMap.COUPON_MANAGER_ADAPTER === c.id) { - const chainDetails = getNetworkDetails("mainnet"); - return { - ...c, - deploymentArgs: { - chainId: chainDetails?.chainId, - }, - }; - } - return c; - }); +export const contracts: Array = defaultContracts.map((c) => { + if (disabled.find((e) => e === c.name)) { + return { ...c, enabled: false }; + } + return c; +}); diff --git a/migrations/configs/rinkeby.config.ts b/migrations/configs/rinkeby.config.ts index cde5f5204..6091e9eba 100644 --- a/migrations/configs/rinkeby.config.ts +++ b/migrations/configs/rinkeby.config.ts @@ -1,6 +1,7 @@ -import { adaptersIdsMap } from "../../utils/dao-ids-util"; -import { contracts as defaultContracts } from "./contracts.config"; -import { getNetworkDetails } from "../../utils/deployment-util"; +import { + contracts as defaultContracts, + ContractConfig, +} from "./contracts.config"; const disabled: Array = [ // Utility & Test Contracts disabled by default @@ -14,22 +15,9 @@ const disabled: Array = [ "MockDao", ]; -export const contracts = defaultContracts - .map((c) => { - if (disabled.find((e) => e === c.name)) { - return { ...c, enabled: false }; - } - return c; - }) - .map((c) => { - if (adaptersIdsMap.COUPON_MANAGER_ADAPTER === c.id) { - const chainDetails = getNetworkDetails("rinkeby"); - return { - ...c, - deploymentArgs: { - chainId: chainDetails?.chainId, - }, - }; - } - return c; - }); +export const contracts: Array = defaultContracts.map((c) => { + if (disabled.find((e) => e === c.name)) { + return { ...c, enabled: false }; + } + return c; +}); diff --git a/subgraph/mappings/core/dao-constants.ts b/subgraph/mappings/core/dao-constants.ts index fd7ff746e..0fa68eca6 100644 --- a/subgraph/mappings/core/dao-constants.ts +++ b/subgraph/mappings/core/dao-constants.ts @@ -13,6 +13,9 @@ export let TOTAL: Address = Address.fromString( export let MEMBER_COUNT: Address = Address.fromString( "0x00000000000000000000000000000000decafbad" ); +export let ESCROW: Address = Address.fromString( + "0x0000000000000000000000000000000000004bec" +); // adapter/extension names hashed (lowercase) diff --git a/subgraph/mappings/extensions/bank-extension-mapping.ts b/subgraph/mappings/extensions/bank-extension-mapping.ts index ddec19744..b276bf50e 100644 --- a/subgraph/mappings/extensions/bank-extension-mapping.ts +++ b/subgraph/mappings/extensions/bank-extension-mapping.ts @@ -14,11 +14,12 @@ import { Extension, } from "../../generated/schema"; import { + ERC20_EXTENSION_ID, + ESCROW, GUILD, - UNITS, - TOTAL, MEMBER_COUNT, - ERC20_EXTENSION_ID, + TOTAL, + UNITS, } from "../core/dao-constants"; function internalTransfer( @@ -38,9 +39,11 @@ function internalTransfer( TOTAL.toHex() != memberAddress.toHex() && GUILD.toHex() != memberAddress.toHex() && MEMBER_COUNT.toHex() != memberAddress.toHex() && + ESCROW.toHex() != memberAddress.toHex() && TOTAL.toHex() != tokenAddress.toHex() && GUILD.toHex() != tokenAddress.toHex() && - MEMBER_COUNT.toHex() != tokenAddress.toHex() + MEMBER_COUNT.toHex() != tokenAddress.toHex() && + ESCROW.toHex() != tokenAddress.toHex() ) { // check if the DAO has an ERC20 extension and assign members balance internalERC20Balance(daoAddress, memberAddress); @@ -85,12 +88,20 @@ function internalTransfer( member.save(); } - // get totalUnits in the dao + // get total units minted for the DAO let balanceOfTotalUnits = bankRegistry.balanceOf(TOTAL, UNITS); + // get balance of units owned by the guild bank + let balanceOfGuildUnits = bankRegistry.balanceOf(GUILD, UNITS); + // get total units issued and outstanding in the DAO (not owned by guild bank) + let balanceOfTotalUnitsIssued = balanceOfTotalUnits.minus( + balanceOfGuildUnits + ); + let dao = TributeDao.load(daoAddress.toHexString()); if (dao != null) { dao.totalUnits = balanceOfTotalUnits.toString(); + dao.totalUnitsIssued = balanceOfTotalUnitsIssued.toString(); dao.save(); } diff --git a/subgraph/mappings/helpers/proposal-details.ts b/subgraph/mappings/helpers/proposal-details.ts index 2aa279f43..0f6911255 100644 --- a/subgraph/mappings/helpers/proposal-details.ts +++ b/subgraph/mappings/helpers/proposal-details.ts @@ -168,10 +168,10 @@ function managing( let proposal = Proposal.load(daoProposalId); if (proposal) { - proposal.adapterId = data.value0; - proposal.adapterAddress = data.value1; + proposal.adapterOrExtensionId = data.value0; + proposal.adapterOrExtensionAddr = data.value1; - proposal.adapterAddress = adapterAdddress; + proposal.adapterOrExtensionAddr = adapterAdddress; // @todo // let keys: Bytes[] = []; diff --git a/subgraph/mappings/helpers/vote-results.ts b/subgraph/mappings/helpers/vote-results.ts index 3880258d5..82f3a2867 100644 --- a/subgraph/mappings/helpers/vote-results.ts +++ b/subgraph/mappings/helpers/vote-results.ts @@ -86,9 +86,9 @@ export function loadProposalAndSaveVoteResults( proposal.gracePeriodStartingTime = voteResults.value6; proposal.isChallenged = voteResults.value7; proposal.stepRequested = voteResults.value8; + proposal.forceFailed = voteResults.value9; // @todo its a mapping, not generated in schema // proposal.fallbackVotes = voteResults.value10; - proposal.forceFailed = voteResults.value9; proposal.fallbackVotesCount = voteResults.value10; proposal.votingState = voteState.toString(); diff --git a/subgraph/schema.graphql b/subgraph/schema.graphql index 9f8604fac..e87110aac 100644 --- a/subgraph/schema.graphql +++ b/subgraph/schema.graphql @@ -22,7 +22,10 @@ type TributeDao @entity { "The DAO creator address" creator: Bytes createdAt: String + "Total units minted for the DAO" totalUnits: String + "Total units issued and outstanding" + totalUnitsIssued: String "The bank of the DAO" bank: Bank! @derivedFrom(field: "tributeDao") "List of registered adapters" @@ -119,6 +122,8 @@ type Proposal @entity { # MANAGING; proposal details "Additional details for the managing proposal" + adapterOrExtensionId: Bytes + adapterOrExtensionAddr: Bytes keys: [Bytes!] values: [BigInt!] @@ -134,8 +139,8 @@ type Proposal @entity { gracePeriodStartingTime: BigInt isChallenged: Boolean stepRequested: BigInt - # fallbackVotes: BigInt forceFailed: Boolean + # fallbackVotes: BigInt fallbackVotesCount: BigInt # ONCHAIN VOTES: additional info diff --git a/utils/deployment-util.js b/utils/deployment-util.js index 622ec79da..838507d9d 100644 --- a/utils/deployment-util.js +++ b/utils/deployment-util.js @@ -469,11 +469,11 @@ const configureDao = async ({ .then(() => contractConfigs.daoConfigs.reduce( (q, configEntry) => - q.then(() => { + q.then(async () => { const configValues = configEntry.map((configName) => readConfigValue(configName, contractConfigs.name) ); - return adapter + return await adapter .configureDao(...configValues, { from: options.owner, })