This commit is contained in:
sairaj mote 2023-09-25 02:51:21 +05:30
parent af0ecf4a13
commit 1ebbf51bb4

View File

@ -2852,17 +2852,23 @@
}
function filterSmartContracts(options) {
const { type, subType, dynamic = false } = options || {}
let filteredSmartContracts = (floGlobals.smartContracts || [])
.filter(sc => sc.status === 'active')
const { type, subType, dynamic = false } = options || {};
let filteredSmartContracts = floGlobals.smartContracts || [];
if (type) {
filteredSmartContracts = filteredSmartContracts.filter(sc => sc.contractType === type)
if (type === 'continuos-event' && dynamic)
filteredSmartContracts = filteredSmartContracts.filter(sc => sc.oracle_address)
filteredSmartContracts = filteredSmartContracts.filter(sc => {
if (type === 'external-trigger') {
return sc.status !== 'active'; // only inactive contracts can be triggered externally
} else if (type === 'continuos-event' && dynamic) {
return sc.status === 'active' && sc.contractType === type && sc.oracle_address;
} else {
return sc.status === 'active' && sc.contractType === type;
}
});
}
if (subType)
filteredSmartContracts = filteredSmartContracts.filter(sc => sc.contractSubType === subType)
return filteredSmartContracts
if (subType) {
filteredSmartContracts = filteredSmartContracts.filter(sc => sc.contractSubType === subType);
}
return filteredSmartContracts;
}
function handleSmartContractSelection(actionType) {