diff --git a/src/hooks/DAO/proposal/usePrepareProposal.ts b/src/hooks/DAO/proposal/usePrepareProposal.ts index e81a71463c..d8ca234c08 100644 --- a/src/hooks/DAO/proposal/usePrepareProposal.ts +++ b/src/hooks/DAO/proposal/usePrepareProposal.ts @@ -10,20 +10,26 @@ export function usePrepareProposal() { async (values: CreateProposalForm) => { const { transactions, proposalMetadata } = values; const transactionsWithEncoding = transactions.map(tx => { - return { - ...tx, - encodedFunctionData: encodeFunction( - tx.functionName, - tx.parameters.map(parameter => parameter.signature.trim()).join(', '), - tx.parameters - .map(parameter => - isValidUrl(parameter.value!.trim()) - ? encodeURIComponent(parameter.value!.trim()) // If parameter.value is valid URL with special symbols like ":" or "?" - decoding might fail, thus we need to encode URL - : parameter.value!.trim(), - ) - .join(', '), - ), - }; + if (!tx.functionName) { + return { + ...tx, + calldata: '0x', + }; + } else { + const signature = tx.parameters.map(parameter => parameter.signature.trim()).join(', '); + const parameters = tx.parameters + .map(parameter => + isValidUrl(parameter.value!.trim()) + ? encodeURIComponent(parameter.value!.trim()) // If parameter.value is valid URL with special symbols like ":" or "?" - decoding might fail, thus we need to encode URL + : parameter.value!.trim(), + ) + .join(', '); + + return { + ...tx, + calldata: encodeFunction(tx.functionName, signature, parameters), + }; + } }); const targets = await Promise.all( transactionsWithEncoding.map(tx => { @@ -33,12 +39,11 @@ export function usePrepareProposal() { return tx.targetAddress; }), ); + return { targets, values: transactionsWithEncoding.map(transaction => transaction.ethValue.bigNumberValue!), - calldatas: transactionsWithEncoding.map( - transaction => transaction.encodedFunctionData || '', - ), + calldatas: transactionsWithEncoding.map(transaction => transaction.calldata || ''), metaData: { title: proposalMetadata.title, description: proposalMetadata.description,