diff --git a/apps/core-app/src/components/proposalCards/ReadyForProcessing.tsx b/apps/core-app/src/components/proposalCards/ReadyForProcessing.tsx index 86b8be024..3995012d8 100644 --- a/apps/core-app/src/components/proposalCards/ReadyForProcessing.tsx +++ b/apps/core-app/src/components/proposalCards/ReadyForProcessing.tsx @@ -17,6 +17,9 @@ import { ACTION_TX } from '../../legos/tx'; import { GatedButton } from './GatedButton'; import { VotingBar } from '../VotingBar'; +// Adding to the gas limit to account for cost of processProposal +export const PROCESS_PROPOSAL_GAS_LIMIT_ADDITION = 150000; + const ProcessBox = styled.div` display: flex; justify-content: flex-start; @@ -40,7 +43,10 @@ export const ReadyForProcessing = ({ const [isLoading, setIsLoading] = React.useState(false); const processProposal = async () => { - const { proposalId, proposalData } = proposal; + const { proposalId, proposalData, actionGasEstimate } = proposal; + const processingGasLimit = ( + Number(actionGasEstimate) + PROCESS_PROPOSAL_GAS_LIMIT_ADDITION + ).toFixed(); if (!proposalId) return; setIsLoading(true); @@ -48,6 +54,7 @@ export const ReadyForProcessing = ({ tx: { ...ACTION_TX.PROCESS, staticArgs: [proposalId, proposalData], + overrides: { gasLimit: processingGasLimit }, } as TXLego, lifeCycleFns: { onTxError: (error) => { diff --git a/apps/core-app/src/pages/ProposalDetails.tsx b/apps/core-app/src/pages/ProposalDetails.tsx index 39a182e28..cdae193d7 100644 --- a/apps/core-app/src/pages/ProposalDetails.tsx +++ b/apps/core-app/src/pages/ProposalDetails.tsx @@ -51,8 +51,6 @@ export function ProposalDetails() { >(); const [proposalLoading, setProposalLoading] = useState(false); - console.log('proposal', proposal); - useEffect(() => { let shouldUpdate = true; if (daochain && daoid && proposalId) { diff --git a/apps/core-app/src/utils/constants.ts b/apps/core-app/src/utils/constants.ts index aa4f5b4a7..7597b2f5a 100644 --- a/apps/core-app/src/utils/constants.ts +++ b/apps/core-app/src/utils/constants.ts @@ -1,5 +1,3 @@ -import { Ordering, Proposal_OrderBy } from '@daohaus/dao-data'; - export const PROPOSAL_FILTERS: { [key: string]: string } = { unsponsored: 'Unsponsored', voting: 'In Voting', diff --git a/apps/v3-subgraph/src/baal-mapping.ts b/apps/v3-subgraph/src/baal-mapping.ts index 3c2bcd117..faf0d19dc 100644 --- a/apps/v3-subgraph/src/baal-mapping.ts +++ b/apps/v3-subgraph/src/baal-mapping.ts @@ -188,7 +188,6 @@ export function handleSubmitProposal(event: SubmitProposal): void { proposal.prevProposalId = event.params.selfSponsor ? dao.latestSponsoredProposalId : constants.BIGINT_ZERO; - proposal.prevProposalId = constants.BIGINT_ZERO; proposal.votingStarts = event.params.selfSponsor ? event.block.timestamp : constants.BIGINT_ZERO; diff --git a/libs/common-utilities/src/constants/endpoints.ts b/libs/common-utilities/src/constants/endpoints.ts index 4a6ccd2ea..27105c13e 100644 --- a/libs/common-utilities/src/constants/endpoints.ts +++ b/libs/common-utilities/src/constants/endpoints.ts @@ -29,7 +29,9 @@ export const ENDPOINTS: KeychainList = { }, GAS_ESTIMATE: { '0x5': - 'https://safe-transaction.goerli.gnosis.io/api/v1/safes/0x1A3Bc7b8Df22eC917aB4260a951987D975906843/multisig-transactions/estimations/', + 'https://safe-transaction.goerli.gnosis.io/api/v1/safes/<>/multisig-transactions/estimations/', + '0x64': + 'https://safe-transaction.goerli.gnosis.io/api/v1/safes/<>/multisig-transactions/estimations/', }, GNOSIS_SAFE_UI: { '0x1': 'https://gnosis-safe.io/app/eth', diff --git a/libs/common-utilities/src/types/legoTypes.ts b/libs/common-utilities/src/types/legoTypes.ts index 36469d381..e52653acb 100644 --- a/libs/common-utilities/src/types/legoTypes.ts +++ b/libs/common-utilities/src/types/legoTypes.ts @@ -112,6 +112,14 @@ export type TxStates = | 'failed' | 'success'; +export type TXOverrides = { + gasLimit?: string; + value?: string; + gasPrice?: string; + from?: string; + blockTag?: string; +}; + export type TXLegoBase = { id: string; contract: ContractLego; @@ -120,6 +128,7 @@ export type TXLegoBase = { args?: ValidArgType[]; argCallback?: string; staticArgs?: ArgType[]; + overrides?: TXOverrides; }; export type TXLego = RequireOnlyOne< diff --git a/libs/dao-data/src/utils/transformers.ts b/libs/dao-data/src/utils/transformers.ts index 79d85d9ce..02d77a1fb 100644 --- a/libs/dao-data/src/utils/transformers.ts +++ b/libs/dao-data/src/utils/transformers.ts @@ -105,14 +105,17 @@ export const addDaoProfileFields = ( obj.links && typeof obj.links === 'string' ? JSON.parse(obj.links) : obj.links; + + const avatarUrl = + obj.avatarImg && obj.avatarImg.match(/Qm[a-zA-Z0-9/.]+/) + ? `https://daohaus.mypinata.cloud/ipfs/${obj.avatarImg.match( + /Qm[a-zA-Z0-9/.]+/ + )}` + : obj.avatarImg; return { description: obj.description, longDescription: obj.longDescription, - avatarImg: - obj.avatarImg && - `https://daohaus.mypinata.cloud/ipfs/${obj.avatarImg.match( - /Qm[a-zA-Z0-9/.]+/ - )}`, + avatarImg: avatarUrl, tags: obj.tags, links, }; diff --git a/libs/tx-builder-feature/src/utils/args.ts b/libs/tx-builder-feature/src/utils/args.ts index 92669b81a..d80a3cc31 100644 --- a/libs/tx-builder-feature/src/utils/args.ts +++ b/libs/tx-builder-feature/src/utils/args.ts @@ -120,6 +120,7 @@ export const processArg = async ({ return result; } if (arg?.type === 'estimateGas') { + console.log('********ESTIMATE'); const result = await handleGasEstimate({ arg, chainId, diff --git a/libs/tx-builder-feature/src/utils/contractHelpers.ts b/libs/tx-builder-feature/src/utils/contractHelpers.ts index e1bb92811..ca6b3dccc 100644 --- a/libs/tx-builder-feature/src/utils/contractHelpers.ts +++ b/libs/tx-builder-feature/src/utils/contractHelpers.ts @@ -25,7 +25,6 @@ const findTargetAddress = ({ targetAddress: StringSearch | Keychain; chainId: ValidNetwork; }) => { - console.log('targetAddress', targetAddress, chainId, appState); if (typeof targetAddress === 'string' && isSearchArg(targetAddress)) { return searchArg({ searchString: targetAddress, diff --git a/libs/tx-builder-feature/src/utils/multicall.ts b/libs/tx-builder-feature/src/utils/multicall.ts index 8db21769b..1064be3b7 100644 --- a/libs/tx-builder-feature/src/utils/multicall.ts +++ b/libs/tx-builder-feature/src/utils/multicall.ts @@ -194,13 +194,16 @@ export const handleGasEstimate = async ({ actions: arg.actions, }, }); + const estimate = await estimateGas({ chainId, safeId, data: proposalData, }); + + console.log('estimate', estimate); if (estimate.safeTxGas) { - const buffer = arg.bufferPercentage ? `1.${arg.bufferPercentage}` : 1.3; + const buffer = arg.bufferPercentage ? `1.${arg.bufferPercentage}` : 1.6; return Math.round(Number(estimate.safeTxGas) * Number(buffer)); } else { throw new Error(`Failed to estimate gas: `); @@ -242,13 +245,9 @@ export const buildMultiCallTX = ({ fallback: 0, }, { - type: 'static', - value: 0, + type: 'estimateGas', + actions, }, - // { - // type: 'estimateGas', - // actions, - // }, JSONDetails, ], }; diff --git a/libs/tx-builder-feature/src/utils/overrides.ts b/libs/tx-builder-feature/src/utils/overrides.ts new file mode 100644 index 000000000..5fcead373 --- /dev/null +++ b/libs/tx-builder-feature/src/utils/overrides.ts @@ -0,0 +1,16 @@ +import { ArbitraryState, TXOverrides } from '@daohaus/common-utilities'; + +export const processOverrides = ({ + overrideArgs, + appState, +}: { + overrideArgs?: TXOverrides; + appState: ArbitraryState; +}): TXOverrides => { + return { + value: appState['formValues']?.proposalOffering + ? Number(appState['formValues']?.proposalOffering).toFixed() + : '0', + ...overrideArgs, + }; +}; diff --git a/libs/tx-builder-feature/src/utils/txBuilderUtils.ts b/libs/tx-builder-feature/src/utils/txBuilderUtils.ts index 0efe68f51..5a3173a32 100644 --- a/libs/tx-builder-feature/src/utils/txBuilderUtils.ts +++ b/libs/tx-builder-feature/src/utils/txBuilderUtils.ts @@ -12,6 +12,7 @@ import { pollLastTX, standardGraphPoll, testLastTX } from './polling'; import { processArgs } from './args'; import { processContractLego } from './contractHelpers'; import { ArgCallback, TXLifeCycleFns } from '../TXBuilder'; +import { processOverrides } from './overrides'; export type TxRecord = Record; export type MassState = { @@ -141,14 +142,10 @@ export async function prepareTX(args: { console.log('**PROCESSED ARGS**', processedArgs); - // TODO for gasLimit and value - // const processOverrides = await - // looks in the lego and gets value and/or gasLimit - // returns {} or { - // value: '1000000000', - // gasLimit: '1000000', - // } - // add new overrides to tx lego and it can use the process args stuff and all current arg types + const overrides = processOverrides({ + overrideArgs: tx.overrides, + appState, + }); const contract = new ethers.Contract( address, @@ -157,12 +154,11 @@ export async function prepareTX(args: { ); lifeCycleFns?.onRequestSign?.(); - // const ethersTx = await contract.functions[method](...processedArgs, { - // value: '1000000000', - // gasLimit: '1000000', - // }); - const ethersTx = await contract.functions[method](...processedArgs); + const ethersTx = await contract.functions[method]( + ...processedArgs, + overrides + ); executeTx({ ...args, ethersTx }); } catch (error) { console.log('**TX Error (Pre-Fire)**');