diff --git a/README.md b/README.md index 57a0f713..bafa55ca 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ This includes following key features: - BP Voting and Governance - Premium Name bids -Following, excelent products can be taken as reference points for further features: +Following, excellent products can be taken as reference points for further features: - [EOS Authority](https://eosauthority.com/) - [Blocks](https://bloks.io/) @@ -112,7 +112,7 @@ app running at localhost:4000 [Vue 2 documentation](https://vuejs.org/v2/api/) -[Vue 3 documenation](https://v3.vuejs.org/) +[Vue 3 documentation](https://v3.vuejs.org/) [Testing Quasar with Jest](https://github.com/quasarframework/quasar-testing/tree/next/packages/unit-jest) diff --git a/src/config/ConfigManager.ts b/src/config/ConfigManager.ts index 4bfb994a..1a0645bc 100644 --- a/src/config/ConfigManager.ts +++ b/src/config/ConfigManager.ts @@ -96,13 +96,23 @@ export default class ConfigManager { } private findChain(chainName: string) { - const fromMainnet = this.mainnets.find( + let fromMainnet = this.mainnets.find( c => c.getName() === chainName, ); if (fromMainnet) { return fromMainnet; + } else { + fromMainnet = this.testnets.find(c => c.getName() === chainName); } - return this.testnets.find(c => c.getName() === chainName); + if (fromMainnet) { + return fromMainnet; + } else { + if (typeof chainName === 'string') { + throw new Error(`Chain '${chainName}' not found`); + } else { + throw new Error('CHAIN_NAME env variable not found'); + } + } } } diff --git a/src/pages/ProposalItem.vue b/src/pages/ProposalItem.vue index 98c51ee0..425a41cb 100644 --- a/src/pages/ProposalItem.vue +++ b/src/pages/ProposalItem.vue @@ -40,6 +40,8 @@ export default defineComponent({ const multsigTransactionData = ref([]); const requestedApprovalsRows = ref([]); + const activeProducers = ref([]); + const activeProducersApproved = ref([]); const requestedApprovalsColumns = [ { @@ -99,15 +101,7 @@ export default defineComponent({ !isCanceled.value )); - const producersApprovalStatus = computed(() => { - const allProducers = requestedApprovalsRows.value.filter( - item => item.isBp, - ); - const producersHaveAlreadyApproved = allProducers.filter( - item => item.status, - ); - return `${producersHaveAlreadyApproved.length}/${allProducers.length}`; - }); + const producersApprovalStatus = computed(() => `${activeProducersApproved.value.length}/${activeProducers.value.length}`); function handleError(e: unknown, defaultMessage: string) { const error = JSON.parse(JSON.stringify(e)) as Error; @@ -282,7 +276,6 @@ export default defineComponent({ proposer.value = proposal.proposer; const totalRequestedApprovals = proposal.provided_approvals.length + proposal.requested_approvals.length; - isApproved.value = proposal.provided_approvals.length === totalRequestedApprovals; approvalStatus.value = `${proposal.provided_approvals.length}/${totalRequestedApprovals}`; isExecuted.value = proposal.executed; @@ -302,6 +295,22 @@ export default defineComponent({ requestedApprovalsRows.value = requestedApprovalsRowsValue; multsigTransactionData.value = multsigTransactionDataValue; + activeProducers.value = requestedApprovalsRows.value.filter( + item => item.isBp, + ); + activeProducersApproved.value = activeProducers.value.filter( + item => item.status, + ); + + if (activeProducers.value.length === 0) { + // No BPs are involved in the proposal, so we need to 100% of the requested approvals + isApproved.value = proposal.provided_approvals.length === totalRequestedApprovals; + } else { + // If BPs are involved, we need 2/3 (+1) of the BPs to approve the proposal + const approval = (activeProducers.value.length * 2 / 3) + 1; + isApproved.value = activeProducersApproved.value.length >= Math.floor(approval); + } + const transactions = await handleTransactionHistory(proposal.block_num); isCanceled.value = transactions.some( diff --git a/yarn.lock b/yarn.lock index 77ed78a4..6fcbc201 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5616,9 +5616,9 @@ flatted@^3.1.0: integrity sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg== follow-redirects@^1.0.0, follow-redirects@^1.14.0: - version "1.15.4" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.4.tgz#cdc7d308bf6493126b17ea2191ea0ccf3e535adf" - integrity sha512-Cr4D/5wlrb0z9dgERpUL3LrmPKVDsETIJhaCMeDfuFYcqa5bldGV6wBsAN6X/vxlXQtFBMrXdXxdL8CbDTGniw== + version "1.15.6" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.6.tgz#7f815c0cda4249c74ff09e95ef97c23b5fd0399b" + integrity sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA== for-in@^1.0.2: version "1.0.2" @@ -6423,9 +6423,9 @@ ip-regex@^4.1.0: integrity sha512-B9ZWJxHHOHUhUjCPrMpLD4xEq35bUTClHM1S6CBU5ixQnkZmwipwgc96vAd7AAGM9TGHvJR+Uss+/Ak6UphK+Q== ip@^1.1.5: - version "1.1.8" - resolved "https://registry.yarnpkg.com/ip/-/ip-1.1.8.tgz#ae05948f6b075435ed3307acce04629da8cdbf48" - integrity sha512-PuExPYUiu6qMBQb4l06ecm6T6ujzhmh+MeJcW9wa89PoAz5pvd4zPgN5WJV104mb6S2T1AwNIAaB70JNrLQWhg== + version "1.1.9" + resolved "https://registry.yarnpkg.com/ip/-/ip-1.1.9.tgz#8dfbcc99a754d07f425310b86a99546b1151e396" + integrity sha512-cyRxvOEpNHNtchU3Ln9KC/auJgup87llfQpQ+t5ghoC/UhL16SWzbueiCsdTnWmqAWl7LadfuwhlqmtOaqMHdQ== ipaddr.js@1.9.1: version "1.9.1" @@ -11618,9 +11618,9 @@ webpack-chain@6.5.1: javascript-stringify "^2.0.1" webpack-dev-middleware@^5.3.1: - version "5.3.3" - resolved "https://registry.yarnpkg.com/webpack-dev-middleware/-/webpack-dev-middleware-5.3.3.tgz#efae67c2793908e7311f1d9b06f2a08dcc97e51f" - integrity sha512-hj5CYrY0bZLB+eTO+x/j67Pkrquiy7kWepMHmUMoPsmcUaeEnQJqFzHJOyxgWlq746/wUuA64p9ta34Kyb01pA== + version "5.3.4" + resolved "https://registry.yarnpkg.com/webpack-dev-middleware/-/webpack-dev-middleware-5.3.4.tgz#eb7b39281cbce10e104eb2b8bf2b63fce49a3517" + integrity sha512-BVdTqhhs+0IfoeAf7EoH5WE+exCmqGerHfDM0IL096Px60Tq2Mn9MAbnaGUe6HiMa41KMCYF19gyzZmBcq/o4Q== dependencies: colorette "^2.0.10" memfs "^3.4.3"