Skip to content

Commit 1cf6039

Browse files
kosAndrey22nicklatkovich-pixelplex
kosAndrey22
andauthored
[EEX-737] Fix Bridge manage contract (#144)
* a * a * a * a * a * a Co-authored-by: NickLatkovich <n.latkovich@pixelplex.io>
1 parent e65cb9b commit 1cf6039

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/actions/ContractActions.js

+15-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
MIN_ACCESS_VERSION_BUILD,
1111
} from '../constants/GlobalConstants';
1212
import { OPERATION_HISTORY_OBJECT_PREFIX } from '../constants/ObjectPrefixesConstants';
13-
import { MODAL_ERROR, MODAL_SUCCESS } from '../constants/ModalConstants';
13+
import { MODAL_ERROR, MODAL_SUCCESS, MODAL_EXTENSION_INFO } from '../constants/ModalConstants';
1414
import { FORM_CONTRACT_VERIFY, FORM_MANAGE_CONTRACT } from '../constants/FormConstants';
1515
import { CONTRACT_ABI } from '../constants/RouterConstants';
1616

@@ -357,16 +357,26 @@ class ContractActions extends BaseActionsClass {
357357
manageContract(contractId, name, icon, description, clickSaveCounter) {
358358
return async (dispatch, getState) => {
359359

360-
const isAccessBridge = await dispatch(GlobalActions.checkAccessToBridge());
361-
if (!isAccessBridge) return;
360+
if (!BridgeService.isExist()) {
361+
dispatch(ModalActions.openModal(MODAL_EXTENSION_INFO, {}));
362+
return;
363+
}
362364

363365
const isExistActiveAccount = await dispatch(AccountActions.checkActiveAccount());
364366
if (!isExistActiveAccount) return;
365367

366368
const ownerName = getState().contract.getIn(['owner', 'name']);
367369
const ownerId = getState().contract.getIn(['owner', 'id']);
368-
const activeAccountId = getState().global.getIn(['activeAccount', 'id']);
369-
370+
let activeAccountId = getState().global.getIn(['activeAccount', 'id']) || BridgeService.getAccount().id;
371+
if (!activeAccountId) {
372+
const access = await BridgeService.getAccess();
373+
if (!access) return;
374+
await new Promise((resolve) =>
375+
setTimeout(() => {
376+
resolve();
377+
}, 300));
378+
activeAccountId = BridgeService.getAccount().id;
379+
}
370380
if (activeAccountId !== ownerId) {
371381
dispatch(ModalActions.openModal(
372382
MODAL_ERROR,

0 commit comments

Comments
 (0)