diff --git a/src/pages/daos/[daoAddress]/proposals/new/CustomProposalSubmitter.tsx b/src/pages/daos/[daoAddress]/proposals/new/CustomProposalSubmitter.tsx new file mode 100644 index 0000000000..ab18b12ba2 --- /dev/null +++ b/src/pages/daos/[daoAddress]/proposals/new/CustomProposalSubmitter.tsx @@ -0,0 +1,80 @@ +import { Button } from '@chakra-ui/react'; +import { useTranslation } from 'react-i18next'; +import { useNavigate } from 'react-router-dom'; +import { DAO_ROUTES } from '../../../../../constants/routes'; +import useSubmitProposal from '../../../../../hooks/DAO/proposal/useSubmitProposal'; +import { ProposalExecuteData } from '../../../../../types'; +import { encodeProposalTransaction } from '../../../../../utils'; + +export default function CustomProposalSubmitter({ + values, + daoAddress, +}: { + values: any; + daoAddress?: string; +}) { + const { submitProposal } = useSubmitProposal(); + const navigate = useNavigate(); + const { t } = useTranslation(['proposal', 'common', 'breadcrumbs']); + + const successCallback = () => { + if (daoAddress) { + navigate(DAO_ROUTES.proposals.relative(daoAddress)); + } + }; + const handleSubmitProposal = () => { + const target = '0x7CC7e125d83A581ff438608490Cc0f7bDff79127'; // SablierV2LockupDynamic + const functionName = 'createWithMilestones'; + const signature = + 'function createWithMilestones(address,address,(address,uint40,bool,bool,address,uint128,(address,uint256),(uint128,uint64,uint40)[])[])'; + const data = [ + '0x7CC7e125d83A581ff438608490Cc0f7bDff79127', + '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', + [ + [ + '0x36bD3044ab68f600f6d3e081056F34f2a58432c4', + 1711980240, + true, + false, + '0x36bD3044ab68f600f6d3e081056F34f2a58432c4', + 25000000000, + ['0x0000000000000000000000000000000000000000', 0], + [ + [0, '1000000000000000000', 1714572239], + [5000000000, '1000000000000000000', 1714572240], + [0, '1000000000000000000', 1717250639], + [5000000000, '1000000000000000000', 1717250640], + [0, '1000000000000000000', 1719842639], + [5000000000, '1000000000000000000', 1719842640], + [0, '1000000000000000000', 1722521039], + [5000000000, '1000000000000000000', 1722521040], + [0, '1000000000000000000', 1725199439], + [5000000000, '1000000000000000000', 1725199440], + ], + ], + ], + ]; + + const { nonce, proposalMetadata } = values; + const calldata = encodeProposalTransaction(functionName, signature, data); + const proposalData: ProposalExecuteData = { + targets: [target], + values: [0], + calldatas: [calldata], + metaData: { + title: proposalMetadata.title, + description: proposalMetadata.description, + documentationUrl: proposalMetadata.documentationUrl, + }, + }; + submitProposal({ + proposalData, + nonce, + pendingToastMessage: t('proposalCreatePendingToastMessage'), + successToastMessage: t('proposalCreateSuccessToastMessage'), + failedToastMessage: t('proposalCreateFailureToastMessage'), + successCallback, + }); + }; + return ; +} diff --git a/src/pages/daos/[daoAddress]/proposals/new/index.tsx b/src/pages/daos/[daoAddress]/proposals/new/index.tsx index 97b36f1f20..1199b27e8e 100644 --- a/src/pages/daos/[daoAddress]/proposals/new/index.tsx +++ b/src/pages/daos/[daoAddress]/proposals/new/index.tsx @@ -18,11 +18,14 @@ import useSubmitProposal from '../../../../../hooks/DAO/proposal/useSubmitPropos import { useCreateProposalSchema } from '../../../../../hooks/schemas/proposalCreate/useCreateProposalSchema'; import { useFractal } from '../../../../../providers/App/AppProvider'; import { CreateProposalForm, CreateProposalState, GovernanceType } from '../../../../../types'; +import CustomProposalSubmitter from './CustomProposalSubmitter'; const templateAreaTwoCol = '"content details"'; const templateAreaSingleCol = `"content" "details"`; +const SHUTTER_DAO_ADDRESS = '0x1CEB4eB34A0AA9D439Dd0A4bab0f6830f715ddF0'; + export default function ProposalCreatePage() { const { node: { daoAddress, safe }, @@ -96,6 +99,7 @@ export default function ProposalCreatePage() { buttonClick={() => navigate(DAO_ROUTES.proposals.relative(daoAddress))} isButtonDisabled={pendingCreateTx} /> + {daoAddress === SHUTTER_DAO_ADDRESS && } { - const calldata = new utils.Interface([signature]).encodeFunctionData(functionName, data); - const stringifiedMetadata = JSON.stringify(metaData); - return { - transaction: { to: target, value: 0, data: calldata, operation: 0 }, - metaData: stringifiedMetadata, - }; + return new utils.Interface([signature]).encodeFunctionData(functionName, data); }; -const target = '0x7CC7e125d83A581ff438608490Cc0f7bDff79127'; // SablierV2LockupDynamic -const functionName = 'createWithMilestones'; -const signature = - 'function createWithMilestones(address,address,(address,uint40,bool,bool,address,uint128,(address,uint256),(uint128,uint64,uint40)[])[])'; -const data = [ - '0x7CC7e125d83A581ff438608490Cc0f7bDff79127', - '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', - [ - [ - '0x36bD3044ab68f600f6d3e081056F34f2a58432c4', - 1711980240, - true, - false, - '0x36bD3044ab68f600f6d3e081056F34f2a58432c4', - 25000000000, - ['0x0000000000000000000000000000000000000000', 0], - [ - [0, '1000000000000000000', 1714572239], - [5000000000, '1000000000000000000', 1714572240], - [0, '1000000000000000000', 1717250639], - [5000000000, '1000000000000000000', 1717250640], - [0, '1000000000000000000', 1719842639], - [5000000000, '1000000000000000000', 1719842640], - [0, '1000000000000000000', 1722521039], - [5000000000, '1000000000000000000', 1722521040], - [0, '1000000000000000000', 1725199439], - [5000000000, '1000000000000000000', 1725199440], - ], - ], - ], -]; - -const metaData = { - title: 'Sablier proposal', - description: 'Sablier proposal description. Markdown supported!', - documentationUrl: '', -}; - -console.log(encodeProposalTransaction(target, functionName, signature, data, metaData)); - export function isMultiSigTx(transaction: ActivityTransactionType): boolean { return transaction.txType === 'MULTISIG_TRANSACTION'; }