Commit 41873701 authored by / /\ / /\/'s avatar / /\ / /\/
Browse files

pass success callback through

parent f177b81f
......@@ -228,9 +228,18 @@ export default connect(
);
},
createCommunity: createCommunityPayload => {
dispatch(
communityActions.createCommunity(createCommunityPayload)
);
const successCallback = () =>
dispatch(
communityActions.communityHivemindOperation(
createCommunityPayload
)
);
const payload = {
successCallback: successCallback,
...createCommunityPayload,
};
debugger;
dispatch(communityActions.createCommunity(payload));
},
};
}
......
......@@ -17,7 +17,8 @@ export const CREATE_COMMUNITY_ACCOUNT_ERROR =
'community/CREATE_COMMUNITY_ACCOUNT_ERROR';
export const CREATE_COMMUNITY_SUCCESS = 'community/CREATE_COMMUNITY_SUCCESS';
const COMMUNITY_HIVEMIND_OPERATION = 'community/COMMUNITY_HIVEMIND_OPERATION'; // Has saga.
export const COMMUNITY_HIVEMIND_OPERATION =
'community/COMMUNITY_HIVEMIND_OPERATION'; // Has saga.
const COMMUNITY_HIVEMIND_OPERATION_PENDING =
'community/COMMUNITY_HIVEMIND_OPERATION_PENDING';
const COMMUNITY_HIVEMIND_OPERATION_ERROR =
......@@ -120,10 +121,13 @@ export const setCommunityOwnerWifPassword = payload => ({
payload,
});
// Has a saga.
export const createCommunity = payload => ({
type: CREATE_COMMUNITY_ACCOUNT,
payload,
});
export const createCommunity = payload => {
debugger;
return {
type: CREATE_COMMUNITY_ACCOUNT,
payload,
};
};
export const createCommunityAccountPending = payload => ({
type: CREATE_COMMUNITY_ACCOUNT_PENDING,
......@@ -138,10 +142,13 @@ export const createCommunitySuccess = payload => ({
payload,
});
export const communityHivemindOperation = payload => ({
type: COMMUNITY_HIVEMIND_OPERATION,
payload,
});
export const communityHivemindOperation = payload => {
debugger;
return {
type: COMMUNITY_HIVEMIND_OPERATION,
payload,
};
};
export const communityHivemindOperationPending = payload => ({
type: COMMUNITY_HIVEMIND_OPERATION_PENDING,
payload,
......
......@@ -37,9 +37,10 @@ export const communityWatches = [
communityActions.CREATE_COMMUNITY_ACCOUNT,
createCommunityAccount
),
takeLatest(communityActions.COMMUNITY_HIVEMIND_OPERATION, customOps),
];
export function* createCommunityAccount(createCommunityAction) {
export function* customOps(action) {
yield put({
type: communityActions.CREATE_COMMUNITY_ACCOUNT_PENDING,
payload: true,
......@@ -51,52 +52,10 @@ export function* createCommunityAccount(createCommunityAction) {
communityNSFW,
communityOwnerName,
communityOwnerWifPassword,
} = createCommunityAction.payload;
successCallback,
} = action.payload;
yield call(wait, 9000);
try {
const op = {
fee: '3.000 STEEM',
creator: accountName,
new_account_name: communityOwnerName,
owner: generateAuth(
communityOwnerName,
communityOwnerWifPassword,
'owner'
),
active: generateAuth(
communityOwnerName,
communityOwnerWifPassword,
'active'
),
posting: generateAuth(
communityOwnerName,
communityOwnerWifPassword,
'posting'
),
memo_key: generateAuth(
communityOwnerPosting,
communityOwnerWifPassword,
'memo'
),
json_metadata: '',
};
yield put(
transactionActions.broadcastOperation({
type: 'account_create',
confirm: 'Are you sure?',
operation: op,
successCallback: res => {
console.log('success', res);
},
errorCallback: res => {
console.log('error', res);
},
})
);
// The client cannot submit custom_json and account_create in the same block. The easiest way around this, for now, is to pause for 3 seconds after the account is created before submitting the ops.
yield call(wait, 9000);
const communityOwnerPosting = auth.getPrivateKeys(
communityOwnerName,
communityOwnerWifPassword,
......@@ -151,22 +110,13 @@ export function* createCommunityAccount(createCommunityAction) {
},
]),
};
debugger;
// SteemJs.
yield broadcast.sendAsync(
{
extensions: [],
operations: [
[
'custom_json',
{
id: 'community',
json: setRoleOperation[1].json,
required_auths: [],
required_posting_auths: [communityOwnerName],
},
],
],
operations: [[setRoleOperation, updatePropsOperation]],
},
[
auth.toWif(
......@@ -188,7 +138,6 @@ export function* createCommunityAccount(createCommunityAction) {
payload: true,
});
} catch (error) {
console.log(error);
yield put({
type: communityActions.CREATE_COMMUNITY_ACCOUNT_ERROR,
payload: true,
......@@ -199,3 +148,82 @@ export function* createCommunityAccount(createCommunityAction) {
payload: false,
});
}
export function* createCommunityAccount(createCommunityAction) {
yield put({
type: communityActions.CREATE_COMMUNITY_ACCOUNT_PENDING,
payload: true,
});
const {
accountName,
communityTitle,
communityDescription,
communityNSFW,
communityOwnerName,
communityOwnerWifPassword,
successCallback,
} = createCommunityAction.payload;
const communityOwnerPosting = auth.getPrivateKeys(
communityOwnerName,
communityOwnerWifPassword,
['posting']
);
try {
const op = {
fee: '3.000 STEEM',
creator: accountName,
new_account_name: communityOwnerName,
owner: generateAuth(
communityOwnerName,
communityOwnerWifPassword,
'owner'
),
active: generateAuth(
communityOwnerName,
communityOwnerWifPassword,
'active'
),
posting: generateAuth(
communityOwnerName,
communityOwnerWifPassword,
'posting'
),
memo_key: generateAuth(
communityOwnerPosting,
communityOwnerWifPassword,
'memo'
),
json_metadata: '',
};
yield put(
transactionActions.broadcastOperation({
type: 'account_create',
confirm: 'Are you sure?',
operation: op,
successCallback: res => {
console.log('success', res);
debugger;
successCallback();
debugger;
},
errorCallback: res => {
console.log('error', res);
},
})
);
// The client cannot submit custom_json and account_create in the same block. The easiest way around this, for now, is to pause for 3 seconds after the account is created before submitting the ops.
} catch (error) {
console.log(error);
yield put({
type: communityActions.CREATE_COMMUNITY_ACCOUNT_ERROR,
payload: true,
});
yield put({
type: communityActions.CREATE_COMMUNITY_ACCOUNT_PENDING,
payload: false,
});
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment