* admin adjustments for proposalId / proposalAddress * ensure fetchProposal called with proposalId * have ProposalCard display proposalAddress
This commit is contained in:
parent
250d5fb7a9
commit
22487b331b
|
@ -33,7 +33,7 @@ class ProposalsNaked extends React.Component<Props> {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const id = this.props.match.params.id;
|
const id = Number(this.props.match.params.id);
|
||||||
const { proposals, proposalsFetched } = store;
|
const { proposals, proposalsFetched } = store;
|
||||||
|
|
||||||
if (!proposalsFetched) {
|
if (!proposalsFetched) {
|
||||||
|
@ -118,7 +118,8 @@ class ProposalItemNaked extends React.Component<Proposal> {
|
||||||
disabled={true}
|
disabled={true}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<b>{p.title}</b> {p.proposalId} <Field title="category" value={p.category} />
|
<b>{p.title}</b> [{p.proposalId}]{p.proposalAddress}{' '}
|
||||||
|
<Field title="category" value={p.category} />
|
||||||
<Field title="dateCreated" value={p.dateCreated * 1000} isTime={true} />
|
<Field title="dateCreated" value={p.dateCreated * 1000} isTime={true} />
|
||||||
<Field title="stage" value={p.stage} />
|
<Field title="stage" value={p.stage} />
|
||||||
<Field
|
<Field
|
||||||
|
@ -230,7 +231,7 @@ const ProposalItem = view(ProposalItemNaked);
|
||||||
|
|
||||||
// tslint:disable-next-line:max-classes-per-file
|
// tslint:disable-next-line:max-classes-per-file
|
||||||
class ContractMethodNaked extends React.Component<
|
class ContractMethodNaked extends React.Component<
|
||||||
TContractMethod & { proposalId: string; name: string }
|
TContractMethod & { proposalId: number; name: string }
|
||||||
> {
|
> {
|
||||||
state = {};
|
state = {};
|
||||||
render() {
|
render() {
|
||||||
|
@ -324,7 +325,7 @@ const ContractMethod = view(ContractMethodNaked);
|
||||||
|
|
||||||
// tslint:disable-next-line:max-classes-per-file
|
// tslint:disable-next-line:max-classes-per-file
|
||||||
class ContractMethodSendNaked extends React.Component<
|
class ContractMethodSendNaked extends React.Component<
|
||||||
TContractMethod & { proposalId: string; name: string }
|
TContractMethod & { proposalId: number; name: string }
|
||||||
> {
|
> {
|
||||||
state = {
|
state = {
|
||||||
args: this.props.input.map(i => (i.type === 'boolean' ? false : '')) as any[],
|
args: this.props.input.map(i => (i.type === 'boolean' ? false : '')) as any[],
|
||||||
|
|
|
@ -54,7 +54,7 @@ async function fetchProposals() {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function deleteProposal(id: string) {
|
async function deleteProposal(id: number) {
|
||||||
const { data } = await api.delete('/admin/proposals/' + id);
|
const { data } = await api.delete('/admin/proposals/' + id);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
@ -144,14 +144,15 @@ const app = store({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async populateProposalContract(proposalId: string) {
|
async populateProposalContract(proposalId: number) {
|
||||||
|
console.log(proposalId);
|
||||||
if (web3) {
|
if (web3) {
|
||||||
await populateProposalContract(app, web3, proposalId);
|
await populateProposalContract(app, web3, proposalId);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async proposalContractSend(
|
async proposalContractSend(
|
||||||
proposalId: string,
|
proposalId: number,
|
||||||
methodName: keyof Contract,
|
methodName: keyof Contract,
|
||||||
inputs: ContractMethodInput[],
|
inputs: ContractMethodInput[],
|
||||||
args: any[],
|
args: any[],
|
||||||
|
@ -161,7 +162,7 @@ const app = store({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async deleteProposal(id: string) {
|
async deleteProposal(id: number) {
|
||||||
try {
|
try {
|
||||||
await deleteProposal(id);
|
await deleteProposal(id);
|
||||||
app.proposals = app.proposals.filter(p => p.proposalId === id);
|
app.proposals = app.proposals.filter(p => p.proposalId === id);
|
||||||
|
|
|
@ -13,7 +13,8 @@ export interface Milestone {
|
||||||
title: string;
|
title: string;
|
||||||
}
|
}
|
||||||
export interface Proposal {
|
export interface Proposal {
|
||||||
proposalId: string;
|
proposalId: number;
|
||||||
|
proposalAddress: string;
|
||||||
dateCreated: number;
|
dateCreated: number;
|
||||||
title: string;
|
title: string;
|
||||||
body: string;
|
body: string;
|
||||||
|
|
|
@ -71,16 +71,17 @@ function checkCrowdFundFactory(app: TApp, web3: Web3) {
|
||||||
export async function proposalContractSend(
|
export async function proposalContractSend(
|
||||||
app: TApp,
|
app: TApp,
|
||||||
web3: Web3,
|
web3: Web3,
|
||||||
proposalId: string,
|
proposalId: number,
|
||||||
methodName: keyof Contract,
|
methodName: keyof Contract,
|
||||||
inputs: ContractMethodInput[],
|
inputs: ContractMethodInput[],
|
||||||
args: any[],
|
args: any[],
|
||||||
) {
|
) {
|
||||||
const storeProposal = app.proposals.find(p => p.proposalId === proposalId);
|
const storeProposal = app.proposals.find(p => p.proposalId === proposalId);
|
||||||
if (storeProposal) {
|
if (storeProposal) {
|
||||||
|
const { proposalAddress } = storeProposal;
|
||||||
await getAccount(app, web3);
|
await getAccount(app, web3);
|
||||||
const storeMethod = storeProposal.contract[methodName];
|
const storeMethod = storeProposal.contract[methodName];
|
||||||
const contract = new web3.eth.Contract(CrowdFund.abi, proposalId);
|
const contract = new web3.eth.Contract(CrowdFund.abi, proposalAddress);
|
||||||
app.crowdFundGeneralStatus = `calling (${storeProposal.title}).${methodName}...`;
|
app.crowdFundGeneralStatus = `calling (${storeProposal.title}).${methodName}...`;
|
||||||
try {
|
try {
|
||||||
console.log(args);
|
console.log(args);
|
||||||
|
@ -120,12 +121,13 @@ export async function proposalContractSend(
|
||||||
export async function populateProposalContract(
|
export async function populateProposalContract(
|
||||||
app: TApp,
|
app: TApp,
|
||||||
web3: Web3,
|
web3: Web3,
|
||||||
proposalId: string,
|
proposalId: number,
|
||||||
) {
|
) {
|
||||||
const storeProposal = app.proposals.find(p => p.proposalId === proposalId);
|
const storeProposal = app.proposals.find(p => p.proposalId === proposalId);
|
||||||
const contract = new web3.eth.Contract(CrowdFund.abi, proposalId);
|
|
||||||
|
|
||||||
if (storeProposal) {
|
if (storeProposal) {
|
||||||
|
const { proposalAddress } = storeProposal;
|
||||||
|
const contract = new web3.eth.Contract(CrowdFund.abi, proposalAddress);
|
||||||
storeProposal.contractStatus = 'loading...';
|
storeProposal.contractStatus = 'loading...';
|
||||||
const methods = Object.keys(INITIAL_CONTRACT).map(k => k as keyof Contract);
|
const methods = Object.keys(INITIAL_CONTRACT).map(k => k as keyof Contract);
|
||||||
for (const method of methods) {
|
for (const method of methods) {
|
||||||
|
@ -137,7 +139,7 @@ export async function populateProposalContract(
|
||||||
try {
|
try {
|
||||||
storeMethod.status = 'loading';
|
storeMethod.status = 'loading';
|
||||||
if (methodType === 'eth' && method === 'getBalance') {
|
if (methodType === 'eth' && method === 'getBalance') {
|
||||||
storeMethod.value = (await web3.eth.getBalance(proposalId)) + '';
|
storeMethod.value = (await web3.eth.getBalance(proposalAddress)) + '';
|
||||||
} else if (methodType === 'array') {
|
} else if (methodType === 'array') {
|
||||||
const result = await collectArrayElements(contractMethod, app.ethAccount);
|
const result = await collectArrayElements(contractMethod, app.ethAccount);
|
||||||
if (method === 'milestones') {
|
if (method === 'milestones') {
|
||||||
|
|
|
@ -76,7 +76,7 @@ export class ProposalCampaignBlock extends React.Component<Props, State> {
|
||||||
|
|
||||||
sendTransaction = () => {
|
sendTransaction = () => {
|
||||||
const { proposal, fundCrowdFund } = this.props;
|
const { proposal, fundCrowdFund } = this.props;
|
||||||
fundCrowdFund(proposal.crowdFundContract, this.state.amountToRaise);
|
fundCrowdFund(proposal, this.state.amountToRaise);
|
||||||
|
|
||||||
this.setState({ amountToRaise: '' });
|
this.setState({ amountToRaise: '' });
|
||||||
};
|
};
|
||||||
|
|
|
@ -90,7 +90,7 @@ class CancelModal extends React.Component<Props> {
|
||||||
};
|
};
|
||||||
|
|
||||||
private cancelProposal = () => {
|
private cancelProposal = () => {
|
||||||
this.props.triggerRefund(this.props.proposal.crowdFundContract);
|
this.props.triggerRefund(this.props.proposal);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -197,12 +197,12 @@ class GovernanceRefunds extends React.Component<Props> {
|
||||||
}
|
}
|
||||||
|
|
||||||
voteRefund = (vote: boolean) => {
|
voteRefund = (vote: boolean) => {
|
||||||
this.props.voteRefund(this.props.proposal.crowdFundContract, vote);
|
this.props.voteRefund(this.props.proposal, vote);
|
||||||
};
|
};
|
||||||
|
|
||||||
withdrawRefund = () => {
|
withdrawRefund = () => {
|
||||||
const { proposal, account } = this.props;
|
const { proposal, account } = this.props;
|
||||||
this.props.withdrawRefund(proposal.crowdFundContract, account);
|
this.props.withdrawRefund(proposal, account);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -234,18 +234,15 @@ export class Milestones extends React.Component<Props> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private requestPayout = (milestoneIndex: number) => {
|
private requestPayout = (milestoneIndex: number) => {
|
||||||
const { crowdFundContract } = this.props.proposal;
|
this.props.requestMilestonePayout(this.props.proposal, milestoneIndex);
|
||||||
this.props.requestMilestonePayout(crowdFundContract, milestoneIndex);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private payPayout = (milestoneIndex: number) => {
|
private payPayout = (milestoneIndex: number) => {
|
||||||
const { crowdFundContract } = this.props.proposal;
|
this.props.payMilestonePayout(this.props.proposal, milestoneIndex);
|
||||||
this.props.payMilestonePayout(crowdFundContract, milestoneIndex);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private votePayout = (milestoneIndex: number, vote: boolean) => {
|
private votePayout = (milestoneIndex: number, vote: boolean) => {
|
||||||
const { crowdFundContract } = this.props.proposal;
|
this.props.voteMilestonePayout(this.props.proposal, milestoneIndex, vote);
|
||||||
this.props.voteMilestonePayout(crowdFundContract, milestoneIndex, vote);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ export class ProposalCard extends React.Component<Props> {
|
||||||
}
|
}
|
||||||
const {
|
const {
|
||||||
title,
|
title,
|
||||||
proposalId,
|
proposalAddress,
|
||||||
proposalUrlId,
|
proposalUrlId,
|
||||||
category,
|
category,
|
||||||
dateCreated,
|
dateCreated,
|
||||||
|
@ -77,7 +77,7 @@ export class ProposalCard extends React.Component<Props> {
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="ProposalCard-address">{proposalId}</div>
|
<div className="ProposalCard-address">{proposalAddress}</div>
|
||||||
|
|
||||||
<div className="ProposalCard-info">
|
<div className="ProposalCard-info">
|
||||||
<div
|
<div
|
||||||
|
|
|
@ -9,7 +9,7 @@ import { fetchProposal, fetchProposals } from 'modules/proposals/actions';
|
||||||
import { PROPOSAL_CATEGORY } from 'api/constants';
|
import { PROPOSAL_CATEGORY } from 'api/constants';
|
||||||
import { AppState } from 'store/reducers';
|
import { AppState } from 'store/reducers';
|
||||||
import { Wei } from 'utils/units';
|
import { Wei } from 'utils/units';
|
||||||
import { TeamMember, AuthSignatureData } from 'types';
|
import { TeamMember, AuthSignatureData, ProposalWithCrowdFund } from 'types';
|
||||||
|
|
||||||
type GetState = () => AppState;
|
type GetState = () => AppState;
|
||||||
|
|
||||||
|
@ -194,20 +194,21 @@ export function resetCreateCrowdFund() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export type TRequestMilestonePayout = typeof requestMilestonePayout;
|
export type TRequestMilestonePayout = typeof requestMilestonePayout;
|
||||||
export function requestMilestonePayout(crowdFundContract: any, index: number) {
|
export function requestMilestonePayout(proposal: ProposalWithCrowdFund, index: number) {
|
||||||
return async (dispatch: Dispatch<any>, getState: GetState) => {
|
return async (dispatch: Dispatch<any>, getState: GetState) => {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: types.REQUEST_MILESTONE_PAYOUT_PENDING,
|
type: types.REQUEST_MILESTONE_PAYOUT_PENDING,
|
||||||
});
|
});
|
||||||
const state = getState();
|
const state = getState();
|
||||||
const account = state.web3.accounts[0];
|
const account = state.web3.accounts[0];
|
||||||
|
const { crowdFundContract, proposalId } = proposal;
|
||||||
try {
|
try {
|
||||||
await crowdFundContract.methods
|
await crowdFundContract.methods
|
||||||
.requestMilestonePayout(index)
|
.requestMilestonePayout(index)
|
||||||
.send({ from: account })
|
.send({ from: account })
|
||||||
.once('confirmation', async () => {
|
.once('confirmation', async () => {
|
||||||
await sleep(5000);
|
await sleep(5000);
|
||||||
await dispatch(fetchProposal(crowdFundContract._address));
|
await dispatch(fetchProposal(proposalId));
|
||||||
dispatch({
|
dispatch({
|
||||||
type: types.REQUEST_MILESTONE_PAYOUT_FULFILLED,
|
type: types.REQUEST_MILESTONE_PAYOUT_FULFILLED,
|
||||||
});
|
});
|
||||||
|
@ -223,20 +224,22 @@ export function requestMilestonePayout(crowdFundContract: any, index: number) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export type TPayMilestonePayout = typeof payMilestonePayout;
|
export type TPayMilestonePayout = typeof payMilestonePayout;
|
||||||
export function payMilestonePayout(crowdFundContract: any, index: number) {
|
export function payMilestonePayout(proposal: ProposalWithCrowdFund, index: number) {
|
||||||
return async (dispatch: Dispatch<any>, getState: GetState) => {
|
return async (dispatch: Dispatch<any>, getState: GetState) => {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: types.PAY_MILESTONE_PAYOUT_PENDING,
|
type: types.PAY_MILESTONE_PAYOUT_PENDING,
|
||||||
});
|
});
|
||||||
const state = getState();
|
const state = getState();
|
||||||
const account = state.web3.accounts[0];
|
const account = state.web3.accounts[0];
|
||||||
|
const { crowdFundContract, proposalId } = proposal;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await crowdFundContract.methods
|
await crowdFundContract.methods
|
||||||
.payMilestonePayout(index)
|
.payMilestonePayout(index)
|
||||||
.send({ from: account })
|
.send({ from: account })
|
||||||
.once('confirmation', async () => {
|
.once('confirmation', async () => {
|
||||||
await sleep(5000);
|
await sleep(5000);
|
||||||
await dispatch(fetchProposal(crowdFundContract._address));
|
await dispatch(fetchProposal(proposalId));
|
||||||
dispatch({
|
dispatch({
|
||||||
type: types.PAY_MILESTONE_PAYOUT_FULFILLED,
|
type: types.PAY_MILESTONE_PAYOUT_FULFILLED,
|
||||||
});
|
});
|
||||||
|
@ -254,7 +257,7 @@ export function payMilestonePayout(crowdFundContract: any, index: number) {
|
||||||
|
|
||||||
// TODO: BigNumber me
|
// TODO: BigNumber me
|
||||||
export type TSendTransaction = typeof fundCrowdFund;
|
export type TSendTransaction = typeof fundCrowdFund;
|
||||||
export function fundCrowdFund(crowdFundContract: any, value: number | string) {
|
export function fundCrowdFund(proposal: ProposalWithCrowdFund, value: number | string) {
|
||||||
return async (dispatch: Dispatch<any>, getState: GetState) => {
|
return async (dispatch: Dispatch<any>, getState: GetState) => {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: types.SEND_PENDING,
|
type: types.SEND_PENDING,
|
||||||
|
@ -262,6 +265,7 @@ export function fundCrowdFund(crowdFundContract: any, value: number | string) {
|
||||||
const state = getState();
|
const state = getState();
|
||||||
const web3 = state.web3.web3;
|
const web3 = state.web3.web3;
|
||||||
const account = state.web3.accounts[0];
|
const account = state.web3.accounts[0];
|
||||||
|
const { crowdFundContract, proposalId } = proposal;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!web3) {
|
if (!web3) {
|
||||||
|
@ -272,7 +276,7 @@ export function fundCrowdFund(crowdFundContract: any, value: number | string) {
|
||||||
.send({ from: account, value: web3.utils.toWei(String(value), 'ether') })
|
.send({ from: account, value: web3.utils.toWei(String(value), 'ether') })
|
||||||
.once('confirmation', async () => {
|
.once('confirmation', async () => {
|
||||||
await sleep(5000);
|
await sleep(5000);
|
||||||
await dispatch(fetchProposal(crowdFundContract._address));
|
await dispatch(fetchProposal(proposalId));
|
||||||
dispatch({
|
dispatch({
|
||||||
type: types.SEND_FULFILLED,
|
type: types.SEND_FULFILLED,
|
||||||
});
|
});
|
||||||
|
@ -289,7 +293,7 @@ export function fundCrowdFund(crowdFundContract: any, value: number | string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function voteMilestonePayout(
|
export function voteMilestonePayout(
|
||||||
crowdFundContract: any,
|
proposal: ProposalWithCrowdFund,
|
||||||
index: number,
|
index: number,
|
||||||
vote: boolean,
|
vote: boolean,
|
||||||
) {
|
) {
|
||||||
|
@ -297,6 +301,7 @@ export function voteMilestonePayout(
|
||||||
dispatch({ type: types.VOTE_AGAINST_MILESTONE_PAYOUT_PENDING });
|
dispatch({ type: types.VOTE_AGAINST_MILESTONE_PAYOUT_PENDING });
|
||||||
const state = getState();
|
const state = getState();
|
||||||
const account = state.web3.accounts[0];
|
const account = state.web3.accounts[0];
|
||||||
|
const { crowdFundContract, proposalId } = proposal;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await crowdFundContract.methods
|
await crowdFundContract.methods
|
||||||
|
@ -304,7 +309,7 @@ export function voteMilestonePayout(
|
||||||
.send({ from: account })
|
.send({ from: account })
|
||||||
.once('confirmation', async () => {
|
.once('confirmation', async () => {
|
||||||
await sleep(5000);
|
await sleep(5000);
|
||||||
await dispatch(fetchProposal(crowdFundContract._address));
|
await dispatch(fetchProposal(proposalId));
|
||||||
dispatch({ type: types.VOTE_AGAINST_MILESTONE_PAYOUT_FULFILLED });
|
dispatch({ type: types.VOTE_AGAINST_MILESTONE_PAYOUT_FULFILLED });
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
@ -318,11 +323,12 @@ export function voteMilestonePayout(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function voteRefund(crowdFundContract: any, vote: boolean) {
|
export function voteRefund(proposal: ProposalWithCrowdFund, vote: boolean) {
|
||||||
return async (dispatch: Dispatch<any>, getState: GetState) => {
|
return async (dispatch: Dispatch<any>, getState: GetState) => {
|
||||||
dispatch({ type: types.VOTE_REFUND_PENDING });
|
dispatch({ type: types.VOTE_REFUND_PENDING });
|
||||||
const state = getState();
|
const state = getState();
|
||||||
const account = state.web3.accounts[0];
|
const account = state.web3.accounts[0];
|
||||||
|
const { crowdFundContract, proposalId } = proposal;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await crowdFundContract.methods
|
await crowdFundContract.methods
|
||||||
|
@ -330,7 +336,7 @@ export function voteRefund(crowdFundContract: any, vote: boolean) {
|
||||||
.send({ from: account })
|
.send({ from: account })
|
||||||
.once('confirmation', async () => {
|
.once('confirmation', async () => {
|
||||||
await sleep(5000);
|
await sleep(5000);
|
||||||
await dispatch(fetchProposal(crowdFundContract._address));
|
await dispatch(fetchProposal(proposalId));
|
||||||
dispatch({ type: types.VOTE_REFUND_FULFILLED });
|
dispatch({ type: types.VOTE_REFUND_FULFILLED });
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
@ -366,15 +372,16 @@ async function freezeContract(crowdFundContract: any, account: string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function triggerRefund(crowdFundContract: any) {
|
export function triggerRefund(proposal: ProposalWithCrowdFund) {
|
||||||
return async (dispatch: Dispatch<any>, getState: GetState) => {
|
return async (dispatch: Dispatch<any>, getState: GetState) => {
|
||||||
dispatch({ type: types.WITHDRAW_REFUND_PENDING });
|
dispatch({ type: types.WITHDRAW_REFUND_PENDING });
|
||||||
const state = getState();
|
const state = getState();
|
||||||
const account = state.web3.accounts[0];
|
const account = state.web3.accounts[0];
|
||||||
|
const { crowdFundContract, proposalId } = proposal;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await freezeContract(crowdFundContract, account);
|
await freezeContract(crowdFundContract, account);
|
||||||
await dispatch(fetchProposal(crowdFundContract._address));
|
await dispatch(fetchProposal(proposalId));
|
||||||
dispatch({ type: types.TRIGGER_REFUND_FULFILLED });
|
dispatch({ type: types.TRIGGER_REFUND_FULFILLED });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
dispatch({
|
dispatch({
|
||||||
|
@ -386,11 +393,12 @@ export function triggerRefund(crowdFundContract: any) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function withdrawRefund(crowdFundContract: any, address: string) {
|
export function withdrawRefund(proposal: ProposalWithCrowdFund, address: string) {
|
||||||
return async (dispatch: Dispatch<any>, getState: GetState) => {
|
return async (dispatch: Dispatch<any>, getState: GetState) => {
|
||||||
dispatch({ type: types.WITHDRAW_REFUND_PENDING });
|
dispatch({ type: types.WITHDRAW_REFUND_PENDING });
|
||||||
const state = getState();
|
const state = getState();
|
||||||
const account = state.web3.accounts[0];
|
const account = state.web3.accounts[0];
|
||||||
|
const { crowdFundContract, proposalId } = proposal;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await freezeContract(crowdFundContract, account);
|
await freezeContract(crowdFundContract, account);
|
||||||
|
@ -399,7 +407,7 @@ export function withdrawRefund(crowdFundContract: any, address: string) {
|
||||||
.send({ from: account })
|
.send({ from: account })
|
||||||
.once('confirmation', async () => {
|
.once('confirmation', async () => {
|
||||||
await sleep(5000);
|
await sleep(5000);
|
||||||
await dispatch(fetchProposal(crowdFundContract._address));
|
await dispatch(fetchProposal(proposalId));
|
||||||
dispatch({ type: types.WITHDRAW_REFUND_FULFILLED });
|
dispatch({ type: types.WITHDRAW_REFUND_FULFILLED });
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
Loading…
Reference in New Issue