From bb5d5b1ee0cd2bd59ae8834725b7ce6a42d584fb Mon Sep 17 00:00:00 2001 From: Rekard0 <5880388+Rekard0@users.noreply.github.com> Date: Tue, 24 Aug 2021 12:28:35 +0200 Subject: [PATCH] Update feature/127/170/171/199 (#465) * update workflows * update workflow * fix hardhat-deploy (#312) * fix hardhat-deploy * update hardhat-deploy Co-authored-by: Giorgi-Lagidze * Fix Govern queue test issue (#313) * fix test failure if event arguments are structs * fix test failure due to missing event abi * update comment to explain the reason behind chai overwrite * fix unlocked event test case * EOF error fix Co-authored-by: Giorgi-Lagidze * add paths to github action workflow (#314) * add path filtering on the workflows * dummy test workflow * add dummy test file to trigger the test cd * remove dummy test workflow and file * update subgraph * replace govern-console with new console * update packages and gitignore * add public in gitignore * remove .DS_Store * Feature/remove govern console (#316) * replace govern-console with new console * update packages and gitignore * add public in gitignore * remove .DS_Store Co-authored-by: Giorgi-Lagidze * change babel-loader version * add storybook-static in gitignore * Feature/fleek (#319) * add rinkeby fleek * update console's workflow * update console workflow * update govern-console * update fleek * update fleek * update fleek * update fleek * update fleek * update fleek * update fleek * update fleek * update fleek * update fleek * update fleek * update fleek * update fleek * update fleek * update fleek * update fleek * update fleek * Feature/proposaldetails (#324) * Added basic injected wallet and added Subgraph queries for DAOs * Added all subgraph data for daos * Footer in progress * Corrected subgraph query * Added subgraph for fetching proposals and for fetching proposal details * Feature/new proposal flow (#322) * added public folder togitignore * Proposal Flow * few typescript type fixes and routing fix, an id param cannot be passed directly as the first route * Updated correct url change * Corrected url Co-authored-by: Bhanu Sanghi Co-authored-by: bhanusanghi * Dao queries based on new subgraph definition (#318) * Dao queries based on new subgraph definition * update govern workflow * fix eof Co-authored-by: Giorgi Lagidze * Fix/gas dos (#310) * gas dos fix on queue * change erc3000 * max calldatasize for govern-queue schedule * max calldatasize for govern-queue * change verification config * increase executionDelay * add collateral checks * increase executionDelay for dummyconfig * change parameters for govern base factory * update govern subgraph * update govern base factory * update subgraph * verify fix governbase * update rinkeby subgraph Co-authored-by: Giorgi-Lagidze * create default erc3000 config data (#326) * GovernRegistry and GovernBaseFactory addresses in README.md for the Rinkeby testnet updated (#329) * give root role to govern (#330) * give root role to govern * update root rule for queue * freeze root role * fix EOF * update fleek rinkeby for console * update workflow and fleek * update workflow * trigger workflow * update workflow * update workflow * update workflow to include CI warnings * trigger workflow path * Govern integration (#331) * Added basic injected wallet and added Subgraph queries for DAOs * Added all subgraph data for daos * Footer in progress * Corrected subgraph query * create dao with happy path testing, no global config option yet * add more test cases for createDao * add configuration option for dao factory address * renamed filename to follow convention * Added subgraph for fetching proposals and for fetching proposal details * Feature/new proposal flow (#322) * added public folder togitignore * Proposal Flow * few typescript type fixes and routing fix, an id param cannot be passed directly as the first route * Updated correct url change * Corrected url * create esm and umd bundles * add example using createDao for web * updated doc for createDao * fix merge with develop error * add proposal scheduling - TODO fix test with bad config * [WIP] chore: newGover implementation in ts library * fix test failure with schedule proposal * chore: refactor of new govern finished with green tests * WIP: add challenge, veto, resolve, execute proposal.. test still failing. * fix: rollup json added * update govern queue abi * scree 1 and 2 in progress * fix merge issue * schedule proposal with a resolver * screen 3 in progress * essential UI for all 4 screen * clean up * set nonce in schedule * Added Wallet and Proposal Details page. * new proposal button * create dao references used for input fields and checkboxes * make proposal nonce nullable * input field value missed * chore: removed governBaseFactory abi json * Corrected input fields * chore: entirely removed abis from govern package * fix: remove json plugin from umdconfig in rollup * chore: register abi json converted to human readable * challenge works now, but, resolve still fail with DM_INVALID_ADJUDICATION_STATE error * exclude files from jest test coverage * skip challenge test as its now failing with CLK_TOO_MANY_TRANSITIONS * add alchemy archive node * run more tests * fix depcheck error - ethers missing * grant veto power to test user to do veto test - unable to grant veto power * Changed Routing, New Proposal testing in progress * Added govern package with yarn link. Corrected variable name * Updated data to session storage * Working test proposal creation * Govern: fix veto test * bring back test command * fix resolve test failure * Added HashRouter and now storing values in session storage, Added Challenge Proposal Integration WIP * New Proposal Flow. * grid css fix * Added - DAO config fetch * Added extra data pull for challenge proposal * checkbox component * blueswitch component * blue porgressbar component * cleaning up create-dao views impelemnting new components * Added execute proposal function WIP * Removed debuggers * Footer added and lint fixes Co-authored-by: Bhanu Sanghi Co-authored-by: bhanusanghi Co-authored-by: Yuet Loo Wong Co-authored-by: cbrzn Co-authored-by: Rekard0 <5880388+Rekard0@users.noreply.github.com> Co-authored-by: Giorgi Lagidze * change token amount to BigNumberish (#332) * build and install govern in workflow * Govern integration (#333) * Added basic injected wallet and added Subgraph queries for DAOs * Added all subgraph data for daos * Footer in progress * Corrected subgraph query * create dao with happy path testing, no global config option yet * add more test cases for createDao * add configuration option for dao factory address * renamed filename to follow convention * Added subgraph for fetching proposals and for fetching proposal details * Feature/new proposal flow (#322) * added public folder togitignore * Proposal Flow * few typescript type fixes and routing fix, an id param cannot be passed directly as the first route * Updated correct url change * Corrected url * create esm and umd bundles * add example using createDao for web * updated doc for createDao * fix merge with develop error * add proposal scheduling - TODO fix test with bad config * [WIP] chore: newGover implementation in ts library * fix test failure with schedule proposal * chore: refactor of new govern finished with green tests * WIP: add challenge, veto, resolve, execute proposal.. test still failing. * fix: rollup json added * update govern queue abi * scree 1 and 2 in progress * fix merge issue * schedule proposal with a resolver * screen 3 in progress * essential UI for all 4 screen * clean up * set nonce in schedule * Added Wallet and Proposal Details page. * new proposal button * create dao references used for input fields and checkboxes * make proposal nonce nullable * input field value missed * chore: removed governBaseFactory abi json * Corrected input fields * chore: entirely removed abis from govern package * fix: remove json plugin from umdconfig in rollup * chore: register abi json converted to human readable * challenge works now, but, resolve still fail with DM_INVALID_ADJUDICATION_STATE error * exclude files from jest test coverage * skip challenge test as its now failing with CLK_TOO_MANY_TRANSITIONS * add alchemy archive node * run more tests * fix depcheck error - ethers missing * grant veto power to test user to do veto test - unable to grant veto power * Changed Routing, New Proposal testing in progress * Added govern package with yarn link. Corrected variable name * Updated data to session storage * Working test proposal creation * Govern: fix veto test * bring back test command * fix resolve test failure * Added HashRouter and now storing values in session storage, Added Challenge Proposal Integration WIP * New Proposal Flow. * grid css fix * Added - DAO config fetch * Added extra data pull for challenge proposal * checkbox component * blueswitch component * blue porgressbar component * cleaning up create-dao views impelemnting new components * Added execute proposal function WIP * Removed debuggers * Footer added and lint fixes * grid fix for the console page * proposals page fix and load more button fixes to * Dao Main page grd fix * wallet connection handling Co-authored-by: Bhanu Sanghi Co-authored-by: bhanusanghi Co-authored-by: Yuet Loo Wong Co-authored-by: cbrzn Co-authored-by: Rekard0 <5880388+Rekard0@users.noreply.github.com> Co-authored-by: Giorgi Lagidze * Header Title Fixed and Button added for Create DAO (#334) * Added basic injected wallet and added Subgraph queries for DAOs * Added all subgraph data for daos * Footer in progress * Corrected subgraph query * create dao with happy path testing, no global config option yet * add more test cases for createDao * add configuration option for dao factory address * renamed filename to follow convention * Added subgraph for fetching proposals and for fetching proposal details * Feature/new proposal flow (#322) * added public folder togitignore * Proposal Flow * few typescript type fixes and routing fix, an id param cannot be passed directly as the first route * Updated correct url change * Corrected url * create esm and umd bundles * add example using createDao for web * updated doc for createDao * fix merge with develop error * add proposal scheduling - TODO fix test with bad config * [WIP] chore: newGover implementation in ts library * fix test failure with schedule proposal * chore: refactor of new govern finished with green tests * WIP: add challenge, veto, resolve, execute proposal.. test still failing. * fix: rollup json added * update govern queue abi * scree 1 and 2 in progress * fix merge issue * schedule proposal with a resolver * screen 3 in progress * essential UI for all 4 screen * clean up * set nonce in schedule * Added Wallet and Proposal Details page. * new proposal button * create dao references used for input fields and checkboxes * make proposal nonce nullable * input field value missed * chore: removed governBaseFactory abi json * Corrected input fields * chore: entirely removed abis from govern package * fix: remove json plugin from umdconfig in rollup * chore: register abi json converted to human readable * challenge works now, but, resolve still fail with DM_INVALID_ADJUDICATION_STATE error * exclude files from jest test coverage * skip challenge test as its now failing with CLK_TOO_MANY_TRANSITIONS * add alchemy archive node * run more tests * fix depcheck error - ethers missing * grant veto power to test user to do veto test - unable to grant veto power * Changed Routing, New Proposal testing in progress * Added govern package with yarn link. Corrected variable name * Updated data to session storage * Working test proposal creation * Govern: fix veto test * bring back test command * fix resolve test failure * Added HashRouter and now storing values in session storage, Added Challenge Proposal Integration WIP * New Proposal Flow. * grid css fix * Added - DAO config fetch * Added extra data pull for challenge proposal * checkbox component * blueswitch component * blue porgressbar component * cleaning up create-dao views impelemnting new components * Added execute proposal function WIP * Removed debuggers * Footer added and lint fixes * grid fix for the console page * proposals page fix and load more button fixes to * Dao Main page grd fix * wallet connection handling * Govern Console Name and Icon change, create Dao added to the top Co-authored-by: Bhanu Sanghi Co-authored-by: bhanusanghi Co-authored-by: Yuet Loo Wong Co-authored-by: cbrzn Co-authored-by: Rekard0 <5880388+Rekard0@users.noreply.github.com> Co-authored-by: Giorgi Lagidze * Feature/dao 151 integrate challenge execute and veto (#335) * Added WIP for Challenge, Completed integration of Schedule * Fix bugs Co-authored-by: bhanusanghi * Feature/dao 127 dao creation (#336) * Added basic injected wallet and added Subgraph queries for DAOs * Added all subgraph data for daos * Footer in progress * Corrected subgraph query * create dao with happy path testing, no global config option yet * add more test cases for createDao * add configuration option for dao factory address * renamed filename to follow convention * Added subgraph for fetching proposals and for fetching proposal details * Feature/new proposal flow (#322) * added public folder togitignore * Proposal Flow * few typescript type fixes and routing fix, an id param cannot be passed directly as the first route * Updated correct url change * Corrected url * create esm and umd bundles * add example using createDao for web * updated doc for createDao * fix merge with develop error * add proposal scheduling - TODO fix test with bad config * [WIP] chore: newGover implementation in ts library * fix test failure with schedule proposal * chore: refactor of new govern finished with green tests * WIP: add challenge, veto, resolve, execute proposal.. test still failing. * fix: rollup json added * update govern queue abi * scree 1 and 2 in progress * fix merge issue * schedule proposal with a resolver * screen 3 in progress * essential UI for all 4 screen * clean up * set nonce in schedule * Added Wallet and Proposal Details page. * new proposal button * create dao references used for input fields and checkboxes * make proposal nonce nullable * input field value missed * chore: removed governBaseFactory abi json * Corrected input fields * chore: entirely removed abis from govern package * fix: remove json plugin from umdconfig in rollup * chore: register abi json converted to human readable * challenge works now, but, resolve still fail with DM_INVALID_ADJUDICATION_STATE error * exclude files from jest test coverage * skip challenge test as its now failing with CLK_TOO_MANY_TRANSITIONS * add alchemy archive node * run more tests * fix depcheck error - ethers missing * grant veto power to test user to do veto test - unable to grant veto power * Changed Routing, New Proposal testing in progress * Added govern package with yarn link. Corrected variable name * Updated data to session storage * Working test proposal creation * integration functions * handle creating new token * fix: extra line removed * correcting gradient in progressbar * essencial integration complete * custom paper component * circular progress component * adding comments * integrate Create Dao UI with govern package * trying to add missing sessionStorage Co-authored-by: Bhanu Sanghi Co-authored-by: bhanusanghi Co-authored-by: Yuet Loo Wong Co-authored-by: Vamsi Reddy Co-authored-by: cbrzn Co-authored-by: Rekard0 <5880388+Rekard0@users.noreply.github.com> Co-authored-by: c0rv0s * limit increased for prposals (#337) * Feature/dao 184 dao setting views (#339) * subgraph queries for console * add proposal button checks * eslint rearrange * prepare dao setting ui * configure functionality * session storage dependency removed from all pages * Dao main page handled with non existant data Co-authored-by: Rekard0 <5880388+Rekard0@users.noreply.github.com> Co-authored-by: Vamsi * Feature/dao 127 dao creation (#340) * Added basic injected wallet and added Subgraph queries for DAOs * Added all subgraph data for daos * Footer in progress * Corrected subgraph query * create dao with happy path testing, no global config option yet * add more test cases for createDao * add configuration option for dao factory address * renamed filename to follow convention * Added subgraph for fetching proposals and for fetching proposal details * Feature/new proposal flow (#322) * added public folder togitignore * Proposal Flow * few typescript type fixes and routing fix, an id param cannot be passed directly as the first route * Updated correct url change * Corrected url * create esm and umd bundles * add example using createDao for web * updated doc for createDao * fix merge with develop error * add proposal scheduling - TODO fix test with bad config * [WIP] chore: newGover implementation in ts library * fix test failure with schedule proposal * chore: refactor of new govern finished with green tests * WIP: add challenge, veto, resolve, execute proposal.. test still failing. * fix: rollup json added * update govern queue abi * scree 1 and 2 in progress * fix merge issue * schedule proposal with a resolver * screen 3 in progress * essential UI for all 4 screen * clean up * set nonce in schedule * Added Wallet and Proposal Details page. * new proposal button * create dao references used for input fields and checkboxes * make proposal nonce nullable * input field value missed * chore: removed governBaseFactory abi json * Corrected input fields * chore: entirely removed abis from govern package * fix: remove json plugin from umdconfig in rollup * chore: register abi json converted to human readable * challenge works now, but, resolve still fail with DM_INVALID_ADJUDICATION_STATE error * exclude files from jest test coverage * skip challenge test as its now failing with CLK_TOO_MANY_TRANSITIONS * add alchemy archive node * run more tests * fix depcheck error - ethers missing * grant veto power to test user to do veto test - unable to grant veto power * Changed Routing, New Proposal testing in progress * Added govern package with yarn link. Corrected variable name * Updated data to session storage * Working test proposal creation * integration functions * handle creating new token * fix: extra line removed * correcting gradient in progressbar * essencial integration complete * custom paper component * circular progress component * adding comments * integrate Create Dao UI with govern package * trying to add missing sessionStorage * adding aragon voice url * disable create new dao button when no wallet connected * adding validation to create dao Co-authored-by: Bhanu Sanghi Co-authored-by: bhanusanghi Co-authored-by: Yuet Loo Wong Co-authored-by: Vamsi Reddy Co-authored-by: cbrzn Co-authored-by: Giorgi Lagidze Co-authored-by: c0rv0s * fix test failure with big numbers (#343) * add hardhat task to set ens address (#342) * add hardhat task to set ens address * add instruction on how to run the task * Feature/dao 167 add links to aragon voice and proxy (#341) * adding proxy url * fixing feature/dao-189-validate-create-form * big fix with validation * remove un necesary array push * Input Field fixes and uppercase added to input field Co-authored-by: Vamsi * Feature/dao 135 dao configuration UI (#344) * dao setting UI, config population in progress * Input Field fix and Dao Setting page fix * feature/dao-165-implement-frontend * input field width correction Co-authored-by: Vamsi * fix dao settings (#345) * New Proposal Page fixed and beautified (#346) * executor needs to be set before the effect is being returned. (#347) This will solve the ens name issue probably * Hot fix/executor undefined (#348) * executor needs to be set before the effect is being returned. * executor was not persisting on state change * registerToken in vocdoni (#349) * create dao with happy path testing, no global config option yet * add more test cases for createDao * add configuration option for dao factory address * renamed filename to follow convention * [WIP] feat: vocdoni integration * chore: trying to make register token test work * [WIP] chore: use geth for token registration in vocdoni * fix: typo on comment * fix: typo on comment * added vocdoni integration * upgrade dvote libraries to 1.2.0 * temporary disable typescript strict checking to build with dvote libs * fix hardhat config error * remove unused dependency * add EOF line * check before register token, register token without verified position Co-authored-by: cbrzn Co-authored-by: Giorgi Lagidze * Feature/dao 158 dialog for handling transactions to be (#352) * WIP - Working Transaction Keeper, enabled Storybook Relative Imports * Added WIP changes, removed ref from search dao box * Input field changed to work without refs * Added a few changes, removed debuggers * Removed yarn lock file Co-authored-by: Vamsi * Feature/move styled components (#353) * WIP - Working Transaction Keeper, enabled Storybook Relative Imports * Added WIP changes, removed ref from search dao box * Input field changed to work without refs * Added a few changes, removed debuggers * Moved all styled components outside component declaration * small bug fix * Feature/dao 238 issue about createdao (#351) * in progress * set default config by dao-161-add-create-dao-to-go * addressing problem 1 and 2 * add fixes * add fixes Co-authored-by: Giorgi Lagidze * Feature/dao 215 integrate with blockchain (#350) * setting ui integration with govern - inprogress * setting ui handle decimals and input hex - inprogress Co-authored-by: Giorgi Lagidze * add vocdoni dvote * Feature/transaction queue (#357) * refactoring createDao * merging input field refactoring changes into this branch for unified PR * refactoring DaoSetting * searchDaoName and if conditions changed to make it short * review dao seting in progress * refactoring the whole codebase * add setvalues for react-form-hook Co-authored-by: Rekard0 <5880388+Rekard0@users.noreply.github.com> Co-authored-by: Vamsi * Added changes for making grid responsive (#355) Co-authored-by: Giorgi Lagidze * DAO-194 - Added Dao not found page (#356) * Added page for no dao found. Added a numerous fixes for making header and footer positions workable * Bug Fix * Feature/dao search (#358) * Added page for no dao found. Added a numerous fixes for making header and footer positions workable * Bug Fix * Corrected regex bug * Feature/dao search (#361) * Added page for no dao found. Added a numerous fixes for making header and footer positions workable * Bug Fix * Corrected regex bug * Fixes for footer placement * Feature/new additions (#362) * set value fixed for forms * typescript amendments * adding fixes for the refactor (#363) * fix govern test failures (#360) * fix test failures * review comment: use utils.isAddress for consistency * packages update * fix error missing TransactionResponse Co-authored-by: Giorgi Lagidze * Feature/dao 248 script for mainnet ens setup (#359) * ens setup scripts * ens label description update * simplify getEthRegistrar * update favicon and header logo (#364) * add human readable amount message for approvals (#365) * fix id to lower case for daos (#369) * fix id to lower case for daos * daoname changed to lowercase inside the new Dao constructor * Feature/fallback provider (#367) * Added fallback provider, Changed name to augmneted wallet * removed debugs * Moved infura id to constants * Add from validation (#366) * refactoring create dao and adding validations * adding minimum validation to daoSettings * isAdress validation * fix typo * feature/dao-255-validation-type-number * add contract validation * temporary show success for repeating token register * clean up validation Co-authored-by: Giorgi Lagidze * add missing favicon files (#370) * Feature/dao 252 add link to dao settings (#368) * add link to dao settings * minor text formatting changes * Feature/dao 190 etherscan fetch for new action page (#371) * fetch abi from etherscan * add ens support for fetch abi, add form validation * pass fetch function to render fetch button * move fetch logic to new action dialog * handle token already registered (#372) * handle token already registered * convert rules and proof human readable in a proposal * remove unnecessary caption * correcting DAO not found page (#373) * decode proposal action data (#374) * Feature/dao 263 dao ready banner (#375) * fix multiple current config loads * set DAO ready banner * feature/dao-269-weird-footer-logo * fix sizes * Feature/widget proposals (#376) * fetch abi from etherscan * add ens support for fetch abi, add form validation * pass fetch function to render fetch button * move fetch logic to new action dialog * add proposal widgets into components * return empty from widget components * Added styling * Corrected Date Value. Multiplying qith 1000 to convert seconds to milliseconds * Added a function getFormatter value to either get back a string or a link if it a valid IPFS link * Added Field Component * add ipfs check * ipfs check * add createdAt order on daos * fix action data misalign Co-authored-by: Yuet Loo Wong Co-authored-by: Bhanu Sanghi * returns true if contract address is valid (#377) * fix states and colors (#379) * Feat/toast messages (#378) * Toast Messages and wallet connection fix * Enque Toasts, Apply validations on dao search, Searhcable Actions, New proposal Page validations shown through toast. * toast messages added * challenge reason check Co-authored-by: Giorgi Lagidze * add validation to newProposal (#380) * add validation to newProposal * clean up * missing dependency fix (#383) * missing dependency fix * removing extra messages * return undefined account if fallback provider is used * Css fixes (#385) * added css fixes and transaction modal end state * force refresh of proposal page (#382) * Feature/dao 264 execution scheduling modal (#381) * improve schedule proposal flow and redirect to proposal details page * increase execution time to avoid bad delay error when scheduling new proposals * cleanup warning messages * extract message from user cancelling transaction * added redirect option to transaction modal * added missing dependency * use onCompleteAllTransactions() to do redirect for proposal scheduling * fix EOF error * added transaction failure reason * remove unused references * revert back to 30 second latency * Feature/prettier fix (#384) * change prettier config and husky * fix govern symlink * update eslint disable * turn off eslint react scope and unescaped * clean up all warnings * feature/dao-296-storybook-building-error Co-authored-by: Rekard0 <5880388+Rekard0@users.noreply.github.com> * do not show transaction modal if there's error (#386) * fix eslint error (#390) * fix css styling with proposal actions (#389) * Feature/dao 278 transaction modal improvements (#388) * added more details to error dialog and prevent modal closing clicking on backdrop * align transaction items by length * Feature/ipfs handling (#391) * ipfs upload * ipfsinput modification * clean up warnings * api hooks separately * clear AN button wanings * new changes * use conventional naming * update execution delay * button types Co-authored-by: Rekard0 <5880388+Rekard0@users.noreply.github.com> * Feature/dao 290 display network status (#387) * network name, 2x image, challenge card in progress * remove challenge card component * prevent app break if subgraph is down * consider no subgraph in prposal detail and doa detail page * clean up * change node versions in workflows Co-authored-by: Giorgi Lagidze * Feature/dao 290 display network status (#392) * network name, 2x image, challenge card in progress * remove challenge card component * prevent app break if subgraph is down * consider no subgraph in prposal detail and doa detail page * clean up * change node versions in workflows * update node version Co-authored-by: Rekard0 <5880388+Rekard0@users.noreply.github.com> * fix govern test failures (#393) * Feature/new changes (#394) * remove loading state from query * transaction modal optional functions * add ids in query * better way for pagination * remove console logs * remove search input (#397) * build container right before calling proposal.schedule() (#400) * Feature/refactoring 1 (#399) * redesign get token info functionality * redesign get token info functionality * fix loading query hook * fix mustache tag issue * add sample code to get title from ipfs * fix token retrivals + ipfs metadata handler * subgraph changes + ipfs + refactoring * fix errors * proof and rules separate loading * fix formatunits * dao query hook fixed * dao settings validations for amounts * add amount positive validations on dao settings * add buffer concat for ipfs content * flex-start for proposal card content Co-authored-by: Yuet Loo Wong * Testing aragon UI 2 (#401) * install aragon ui v2 * add aragon ui to home page * Create Dao Flow UI Implemtation * feature/dao-328-implement-frontend * cleanup and adding types * fix typo * Feature/dao 297 add polling in proposal detail (#402) * add polling to proposal query * prevent re-rendering * fix error: fewer hooks than expected * console environment (#404) * console environment * moved DAO config from constant to environment * remove obsolete code * connect to provider based on chainId * Feature/dao 391 proposal resolution (#403) * fix typo * render approved as string * Feature/dao 394 implement functionalities (#406) * update contract address in govern * set contract address in tests * start implement functionalities * add newGovern abi * restructure create dao flow * new changes per design and validations Co-authored-by: Rekard0 <5880388+Rekard0@users.noreply.github.com> * add ipfs link to decoded action data (#405) * add ipfs link to decoded action data * fix initial ipfs loading state * concat buffers for ipfs data Co-authored-by: Giorgi Lagidze * Feature/dao 400 update dao setting page (#407) * merge with develop * update setting UI * Update Setting * add new ui components to create dao flow * replace ui component * search fix * update footer * clean up * SUBGRAPH: update ipfs cat fetching * fix title text (#408) * add daofactory in environments * rename create dao * Fix/create dao (#410) * fix create dao small issues * fix ipfs placeholder * Feature/dao 399 new execution flow (#409) * wip: new execution page * refactor, add delete/move up/down buttons * temporary commit with button update and action list move and remove functions * use react-hook-form to manage action list * rename proposals to executions * enable css prop in react element * add stepper component * disable warning of unused variable if variable name starts with underscore * add withdraw, mint and custom execution flow * make first part of address show 4 bytes, excluding 0x * refactor * add required validation rule * remove obsolete code * handle encoding error * cleanup and bug fix * support small layout * validate address field * small layout for action list buttons * fix issue with missing input field name * update aragon ui * remove contract selector form * fix error passing number instead of string for the columns property to Grid * Feature/contract changes (#396) * schedule acl list * fix schedule list when length 0 * add merkle root in govern create * schedule list fixed + test cases * govern base factory better tests * collaterals -- custom schedule/challenge tokens * fix collaterals for govern create * remove abi from gitignore * Govern Executor: add deposit * EOF + uncomment ens * remove eth deposited test * Feature/minter event (#412) * add minter in registry event * fix govern-core tests * fix createdao path * add withdraw (#413) * add withdraw * fix withdraw * Feature/dao 401 deposit asset action flow (#414) * wip: new execution page * refactor, add delete/move up/down buttons * temporary commit with button update and action list move and remove functions * use react-hook-form to manage action list * rename proposals to executions * enable css prop in react element * add stepper component * disable warning of unused variable if variable name starts with underscore * add withdraw, mint and custom execution flow * make first part of address show 4 bytes, excluding 0x * refactor * add required validation rule * remove obsolete code * handle encoding error * cleanup and bug fix * support small layout * validate address field * small layout for action list buttons * deposit form initial version * format signature according to design * add deposit transaction processing status dialog, bug fixes, refactoring * cleanup obsolete code * add minter to dao query * use GovernMinter's mint function * set mint context to 0x * Feature/dao 420 implement fileinput in console (#411) * implement fileInput * clean up * correct folder name typo * quick work arround for react form Co-authored-by: Giorgi Lagidze * small fixes (#415) * small fixes * uncomment tests * Feature/fixes (#417) * new bug fixes * add no-cache * remove queries cache-only * Feature/ara 828 create dao issue with file component (#419) * dont show text file as ipfs file * fix bugs * update ProposalCard * fixing fileInput design bad in small size * clean up warnings * add custom line height * add elipsis to propsal card * Weird text sizing * subgraph fixed * add cursor to ProposalCard Co-authored-by: Rekard0 <5880388+Rekard0@users.noreply.github.com> * Console deposit + withdrawal (#418) * integrate with Govern Executor deposit function * integrate govern withdrawal * remove unused variables * subgraph fixed * handle long function name and argument list * add value field to payable actions * withdraw freeze when public * typo * bring back failuremap * remove nonce from proposaldetails * fix typescript error Co-authored-by: Giorgi Lagidze * Feature/dao 418 create help component for console (#420) * starting help component * adding image * add helpComponent to CreateDao and Setting * subgraph fixed * address list correction * correct parttern for pages * show correct view on progress Co-authored-by: Giorgi Lagidze * Feature/console deposit (#421) * integrate with Govern Executor deposit function * integrate govern withdrawal * remove unused variables * subgraph fixed * handle long function name and argument list * add value field to payable actions * withdraw freeze when public * typo * bring back failuremap * remove nonce from proposaldetails * fix typescript error * clean up duplicate getToken() Co-authored-by: yuetloo * Feature/dao 419 mobile menu (#423) * fix header for mobile * clean up * Show abi input only if contract is not verified. (#422) * fix warning * display abi field only if contract is not verified * show abi field if contract not verified * change header icon (#424) * change icon * move svg icons to the svgs subfolder * update icon (#425) * DAO-35: use aragon ui toast (#426) * replace snackbar with toast * replace ANButton with aragon ui Button * Bug fixing - DAO-32 (#427) * register token cycle correction * remove variant from toast * setting file upload bug fix * fix existing token in create dao bug * console log clean up * fix transaction keeper bug * parcial update transaction dialog ui * add text rule check * add getRule function * update texts * change logo * addressing comments * add beta label to header title (#428) * Feature/ipfs loader (#429) * subgraph fixed * ipfs loader for dao settings ruls * Feature/challenge bug (#430) * subgraph fixed * fix challenge bug if token addresses are the same * Minor Govern ui fixes DAO-40 (#432) * createDao button - only show icon in small view * change create dao button icon * transaction dialog bug fix * move progress to the top * update beta label * correct titles * Clean up * refinement * fix contentswitcher in ipfs * resolve-button (#431) * resolve-button * ipfs gateway link fixed * fix proposal card hash * DAO-52 remove story book (#434) * remove story book from ci job * remove story book * implement file size validation (#435) * remove memo from execute widget (#436) * Enable analytics on govern DAO-38 (#433) * implement analytic * remove warnings and errors * Feature/dao 55 (#437) * contract updates * update workflow * change .env keys * fix factory tests * new deployments (#438) * Wallet fix (#439) * fix wallet address undefined bug * clean up * DAO-63 fix tests (#440) * add missing await * fix test cases * check contract address * temporary exclude hardhat tests using forking as it's broken due to EIP1559 transactions * fix test failures thrown in hardhat getContractAt and getContractFactory * skip ens test * prevent hardhat from estimating gas on getContractAt and getContractFactory * update resolver for staging * Feature/dao 66 (#441) * dao identifer already exists * adding window.scroll * add connect wallet warning on review dao * implement scroll to id * import without relative path Co-authored-by: Rekard0 <5880388+Rekard0@users.noreply.github.com> * Text copy DAO-64 (#442) * Landing page * copy fix * addressing review comments * revert token decimal message Co-authored-by: yuetloo * update dependencies (#443) * fix typo and uppercase * implement analytics event DAO-98 (#445) * implement analytic events * add nav bar event * in progress * add wallet disconnected event * use user account * implement disconnect * clean up * return excecutor from govern.js * return error message * correct naming convention * address comment * DAO-64 addressing comments (#444) * address comment, show title in collateral, remove useEffect in useForm * Feature/fix createdao bug (#447) * feature/fix-createdao-bug * cancel previouse subscriptions * address concern about change in registery address * only create new contract instance if registery address changed * correct typo * refactor govern register event * refactor govern registered event * clean up Co-authored-by: Rekard0 <5880388+Rekard0@users.noreply.github.com> * update govern bug with subgraphs (#448) * fix subgraph * fix subgraph error * update govern executor with subgraphs * update contracts + Subgraph * Bug / DAO-105 (#449) * update aragon ui and clear warnings * update aragon ui to fix contentSwitcher warning * back button integrated (#451) * DAO-77 - changing main agreement copy, helper text, and adding ReactNode and rows as optional props on IPFSInput (#450) * DAO-165 - adding aragon link to footer (#452) * add govern deployments * fix eslint * update resolver for mainnet * DAO-166: changing help texts and re-organising the component (#453) * update contract addresses * Fixing proposal title format for longer titles (#455) * Fixing DAOCard title ellipsis (#456) * Feature/govern deployments (#454) * add govern deployments * fix eslint * update resolver for mainnet * update contract addresses * fleek update * adding helpscout (#458) * Feature / DAO-171 (#459) * implement new dropDown component in createDao * Feature DAO-170 (#460) * UI fixes * change court to Aragon Court * Feature / DAO-127 (#461) * migrate analytics to rudderstack * bug fix * correct analytic variable and add key to ci-cd * Feature / DAO-199 (#463) * create footer area * implement network switcher * use correct loading for delay picker * adding header to dropdown * use GU * use chainId instead of networkName Co-authored-by: Giorgi-Lagidze Co-authored-by: Giorgi Lagidze Co-authored-by: Yuet Wong Co-authored-by: Vamsi Reddy Co-authored-by: Bhanu Sanghi Co-authored-by: bhanusanghi Co-authored-by: Samuel Furter Co-authored-by: cbrzn Co-authored-by: c0rv0s Co-authored-by: Ramon Canales --- .github/workflows/govern-console-ci-cd.yml | 22 ++-- packages/govern-console/public/index.html | 108 ++++++++-------- .../src/components/Header/Header.tsx | 57 ++++++-- .../components/TimeInterval/TimeInterval.tsx | 122 ++++++++++++++++++ .../containers/CreateDao/CreateDaoConfig.tsx | 60 +++++---- .../containers/CreateDao/CreateDaoReview.tsx | 2 +- .../utils/CreateDaoContextProvider.tsx | 8 +- .../src/containers/CreateDao/utils/Shared.tsx | 13 +- .../containers/DAOSettings/DAOSettings.tsx | 49 ++++--- .../src/containers/HomePage/HomePage.tsx | 68 ++++++---- .../components/ChallengeWidget.tsx | 11 +- .../src/environment/networks.ts | 6 +- .../govern-console/src/services/analytics.ts | 2 +- .../govern-console/src/utils/TimeInterval.tsx | 53 ++++++++ .../govern-console/src/utils/constants.tsx | 5 + packages/govern-console/src/utils/types.tsx | 6 + yarn.lock | 2 +- 17 files changed, 428 insertions(+), 166 deletions(-) create mode 100644 packages/govern-console/src/components/TimeInterval/TimeInterval.tsx create mode 100644 packages/govern-console/src/utils/TimeInterval.tsx diff --git a/.github/workflows/govern-console-ci-cd.yml b/.github/workflows/govern-console-ci-cd.yml index 0e922324..57a56c6a 100644 --- a/.github/workflows/govern-console-ci-cd.yml +++ b/.github/workflows/govern-console-ci-cd.yml @@ -27,10 +27,10 @@ jobs: uses: actions/setup-node@v1 with: node-version: 14.15.5 - + - name: Build the Govern run: cd ../govern && yarn install --frozen-lockfile && yarn build - + - name: Install dependencies run: yarn install --frozen-lockfile @@ -39,7 +39,7 @@ jobs: env: REACT_APP_ANALYTICS_KEY: ${{ secrets.REACT_APP_ANALYTICS_KEY }} - - name: Activate rinkeby's fleek + - name: Activate rinkeby's fleek run: mv fleek/console.rinkeby.json .fleek.json - name: deploy console @@ -54,6 +54,7 @@ jobs: container: fleek/create-react-app:node-15 name: builds and deploys console on rinkeby's staging if: github.ref == 'refs/heads/develop' + environment: Rinkeby_Staging defaults: run: working-directory: ${{env.working-directory}} @@ -64,17 +65,19 @@ jobs: uses: actions/setup-node@v1 with: node-version: 14.15.5 - + - name: Build the Govern run: cd ../govern && yarn install --frozen-lockfile && yarn build - + - name: Install dependencies run: yarn install --frozen-lockfile - name: Build the app run: CI='' yarn build:staging + env: + REACT_APP_ANALYTICS_KEY: ${{ secrets.REACT_APP_ANALYTICS_KEY }} - - name: Activate rinkeby's staging's fleek + - name: Activate rinkeby's staging's fleek run: mv fleek/console.rinkeby.staging.json .fleek.json - name: deploy console @@ -100,10 +103,10 @@ jobs: uses: actions/setup-node@v1 with: node-version: 14.15.5 - + - name: Build the Govern run: cd ../govern && yarn install --frozen-lockfile && yarn build - + - name: Install dependencies run: yarn install --frozen-lockfile @@ -112,7 +115,7 @@ jobs: env: REACT_APP_ANALYTICS_KEY: ${{ secrets.REACT_APP_ANALYTICS_KEY }} - - name: Activate mainnet's fleek + - name: Activate mainnet's fleek run: mv fleek/console.mainnet.json .fleek.json - name: deploy console @@ -121,4 +124,3 @@ jobs: with: apiKey: ${{ secrets.FLEEK_API_KEY }} workDir: ${{env.working-directory}} - diff --git a/packages/govern-console/public/index.html b/packages/govern-console/public/index.html index 9c79ef70..2c65fe33 100644 --- a/packages/govern-console/public/index.html +++ b/packages/govern-console/public/index.html @@ -29,60 +29,66 @@ + + + diff --git a/packages/govern-console/src/components/Header/Header.tsx b/packages/govern-console/src/components/Header/Header.tsx index a4e527e0..3b7bad67 100644 --- a/packages/govern-console/src/components/Header/Header.tsx +++ b/packages/govern-console/src/components/Header/Header.tsx @@ -1,7 +1,8 @@ +import React, { useState, useEffect } from 'react'; import governIcon from 'images/svgs/aragon-icon.svg'; import Wallet from 'components/Wallet/Wallet'; import { useHistory } from 'react-router-dom'; -import { Button, StyledText, IconCirclePlus, useLayout, GU, Tag } from '@aragon/ui'; +import { Button, IconCirclePlus, useLayout, GU, Tag, DropDown } from '@aragon/ui'; import styled from 'styled-components'; import { networkEnvironment } from 'environment'; import { trackEvent, EventType } from 'services/analytics'; @@ -9,8 +10,9 @@ import { trackEvent, EventType } from 'services/analytics'; const NavBar = styled.nav` display: flex; flex-direction: row: - gap: 16px; + gap: ${2 * GU}px; padding: 8px; + align-items: center; `; const Title = styled.div` @@ -26,15 +28,28 @@ const RigtSideContainer = styled.div` width: 100%; flex-wrap: nowrap; flex-direction: row; - justify-content: flex-end; align-items: center; - gap: 10px; + gap: ${GU}px; + justify-content: flex-end; `; +// TODO: Temporary and to be removed. +const chainInfo = { + names: ['Mainnet', 'Rinkeby'], + networkIds: [1, 4], + values: ['govern', 'govern-rinkeby'], +}; + const Header = () => { const { layoutName } = useLayout(); const history = useHistory(); - const { networkName } = networkEnvironment; + const { networkName, chainId } = networkEnvironment; + const [selectedNetwork, setSelectedNetwork] = useState(-1); + + useEffect(() => { + const index = chainInfo.networkIds.indexOf(chainId); + setSelectedNetwork(index); + }, [chainId]); const redirectToHomePage = () => { history.push('/'); @@ -53,10 +68,36 @@ const Header = () => { + - {layoutName !== 'small' && ( - Network:{networkName.toUpperCase()} - )} + {/* {layoutName !== 'small' && ( + // TODO: Temporary and to be returned. + // Network:{networkName.toUpperCase()} + )} */} + + {/* // TODO: Temporary and to be removed. */} + + { + if (index !== selectedNetwork) { + const open = window.open(undefined, '_self'); + if (open) { + open.opener = null; + open.location.href = `https://${chainInfo.values[index]}.aragon.org`; + } + } + }} + shadow + iconOnly={layoutName === 'small'} + css={` + height: 40px; + `} + /> + diff --git a/packages/govern-console/src/containers/CreateDao/utils/CreateDaoContextProvider.tsx b/packages/govern-console/src/containers/CreateDao/utils/CreateDaoContextProvider.tsx index da58a006..093eb3b3 100644 --- a/packages/govern-console/src/containers/CreateDao/utils/CreateDaoContextProvider.tsx +++ b/packages/govern-console/src/containers/CreateDao/utils/CreateDaoContextProvider.tsx @@ -1,6 +1,7 @@ import React, { useMemo, useState, useContext, useCallback } from 'react'; import { BigNumber, BytesLike } from 'ethers'; import { networkEnvironment } from 'environment'; +import getInterval from 'utils/TimeInterval'; export interface ICreateDaoBasicInfo { daoIdentifier: string; @@ -14,6 +15,8 @@ export interface ICreateDaoBasicInfo { } export interface ICreateDaoConfig { + delaySelectedIndex: number; + delayInputValue: number; executionDelay: number; isRuleFile: boolean; ruleFile: any; @@ -54,6 +57,7 @@ const UseCreateDao = React.createContext(null); const CreateDaoProvider: React.FC = ({ children }) => { const { defaultDaoConfig: defaultConfig } = networkEnvironment; + const executionDelayIntervals = getInterval(defaultConfig.executionDelay); const [basicInfo, setBasicInfo] = useState({ daoIdentifier: '', @@ -67,7 +71,9 @@ const CreateDaoProvider: React.FC = ({ children }) => { }); const [config, setConfig] = useState({ - executionDelay: parseInt(defaultConfig.executionDelay.toString()), + delaySelectedIndex: executionDelayIntervals?.index || 3, // default to Days's index + delayInputValue: executionDelayIntervals?.value || 7, // default to 7 + executionDelay: defaultConfig.executionDelay, isRuleFile: false, ruleFile: '', ruleText: defaultConfig.rules, diff --git a/packages/govern-console/src/containers/CreateDao/utils/Shared.tsx b/packages/govern-console/src/containers/CreateDao/utils/Shared.tsx index a700858b..58d54c18 100644 --- a/packages/govern-console/src/containers/CreateDao/utils/Shared.tsx +++ b/packages/govern-console/src/containers/CreateDao/utils/Shared.tsx @@ -4,6 +4,7 @@ import { ICreateDaoConfig, ICreateDaoCollaterals, } from './CreateDaoContextProvider'; +import { TIME_INTERVALS } from 'utils/constants'; enum CreateDaoSteps { BasicInfo, @@ -96,19 +97,21 @@ const configArray = (config: ICreateDaoConfig) => { return value && typeof value !== 'string' ? toUtf8String(value) : value; case 'executionDelay': - return `${value} seconds`; + return `${config.delayInputValue} ${TIME_INTERVALS.names[config.delaySelectedIndex]}`; default: return value.toString(); } }; - const filters: (keyof ICreateDaoConfig)[] = !config.isRuleFile - ? ['maxCalldataSize', 'customResolver', 'isRuleFile', 'ruleFile'] - : ['maxCalldataSize', 'customResolver', 'isRuleFile', 'ruleText']; + const filters: (keyof ICreateDaoConfig)[] = [ + 'executionDelay', + 'resolver', + config.isRuleFile ? 'ruleFile' : 'ruleText', + ]; return Object.entries(config) - .filter((entry) => !filters.includes(entry[0] as any)) + .filter((entry) => filters.includes(entry[0] as any)) .map((entry) => ({ name: formatParamNames[entry[0]?.toString()], value: formatValue(entry[0], entry[1]), diff --git a/packages/govern-console/src/containers/DAOSettings/DAOSettings.tsx b/packages/govern-console/src/containers/DAOSettings/DAOSettings.tsx index 260a3a78..6e6c71ee 100644 --- a/packages/govern-console/src/containers/DAOSettings/DAOSettings.tsx +++ b/packages/govern-console/src/containers/DAOSettings/DAOSettings.tsx @@ -21,7 +21,6 @@ import { useDaoQuery } from 'hooks/query-hooks'; import { ipfsMetadata } from 'utils/types'; import { formatUnits, parseUnits } from 'utils/lib'; import { getTokenInfo } from 'utils/token'; -import { positiveNumber } from 'utils/validations'; import { ANCircularProgressWithCaption } from 'components/CircularProgress/ANCircularProgressWithCaption'; import { CircularProgressStatus } from 'utils/types'; @@ -42,6 +41,7 @@ import { } from '@aragon/ui'; import PageContent from 'components/PageContent/PageContent'; import SettingsCard from './components/SettingsCard'; +import { TimeInterval } from 'components/TimeInterval/TimeInterval'; export interface DaoSettingFormProps { /** @@ -63,6 +63,8 @@ interface FormInputs { isRuleFile: boolean; rulesFile: any; proofFile: any; + delaySelectedIndex: number; + delayInputValue: number; } const DaoSettings: React.FC = () => { @@ -78,7 +80,7 @@ const DaoSettings: React.FC = () => { const { control, setValue, getValues, handleSubmit, trigger } = methods; const { daoName } = useParams(); //TODO daoname empty handling - const { data: dao } = useDaoQuery(daoName); + const { data: dao, loading: loadingDaoData } = useDaoQuery(daoName); const [daoDetails, updateDaoDetails] = useState(); const [config, setConfig] = useState(undefined); const [daoAddresses, setDaoAddresses] = useState<{ executorAddress: string; token: string }>({ @@ -101,6 +103,7 @@ const DaoSettings: React.FC = () => { useEffect(() => { if (dao) { + // console.log('getInterval', getInterval(dao.queue?.config?.executionDelay)); updateDaoDetails(dao); } }, [dao]); @@ -316,30 +319,24 @@ const DaoSettings: React.FC = () => { - positiveNumber(value), - }} - render={({ field: { onChange, value }, fieldState: { error } }) => ( - - )} - /> + + {loadingDaoData ? ( + + ) : ( + + )} {ipfsRulesLoading ? ( { const history = useHistory(); @@ -29,28 +47,34 @@ const HomePage = () => { return (
-
- - - - - - - - - history.goBack()} /> - - - - - - history.goBack()} /> - - - - - -
+ + +
+ + + + + + + + + history.goBack()} /> + + + + + + history.goBack()} /> + + + + + + + +
+ +
); diff --git a/packages/govern-console/src/containers/ProposalDetails/components/ChallengeWidget.tsx b/packages/govern-console/src/containers/ProposalDetails/components/ChallengeWidget.tsx index 62f861aa..e5c722cf 100644 --- a/packages/govern-console/src/containers/ProposalDetails/components/ChallengeWidget.tsx +++ b/packages/govern-console/src/containers/ProposalDetails/components/ChallengeWidget.tsx @@ -117,19 +117,10 @@ const ChallengeWidget: React.FC = ({ return ( - {/* - Challenge Reason{' '} - - */} - ([ daoFactoryAddress: '0x8bF05ce17B30f8C73B06e49f67076f944687c967', governRegistryAddress: '0xf2b7D096cd34F228A6413e276132C21D98b19882', defaultDaoConfig: { - executionDelay: 86400, // defaults to one day - how many seconds to wait before being able to call execute. + executionDelay: 604800, // defaults to 7 day - how many seconds to wait before being able to call execute. scheduleDeposit: { token: '0x6b175474e89094c44da98b954eedeac495271d0f', amount: '10000000000000000000', @@ -46,7 +46,7 @@ const networks = new Map([ daoFactoryAddress: '0x46013753f3a02ab4239cA936632E6C6B39235CCE', governRegistryAddress: '0xf46253ef29FaedAbf63AA8cA6c0A41CbbdC93948', defaultDaoConfig: { - executionDelay: 180, + executionDelay: 3600, // 1 Hour scheduleDeposit: { token: '0xc7AD46e0b8a400Bb3C915120d284AafbA8fc4735', amount: '10000000000000000000', @@ -79,7 +79,7 @@ const networks = new Map([ daoFactoryAddress: '0x0f75Dd5E00f0A153fCee92A1C242Dbdf32D87196', governRegistryAddress: '0xcc3F32957d316a12AFCFed04c0716af4814eCB2B', defaultDaoConfig: { - executionDelay: 180, + executionDelay: 180, // 3 minutes scheduleDeposit: { token: '0x8F2Ac3fD1a9Ce7208eFff7C31aC0e2A98b0778f3', amount: '10000000000000000000', diff --git a/packages/govern-console/src/services/analytics.ts b/packages/govern-console/src/services/analytics.ts index 5c7f39d6..49b55d20 100644 --- a/packages/govern-console/src/services/analytics.ts +++ b/packages/govern-console/src/services/analytics.ts @@ -21,7 +21,7 @@ export enum EventType { * @returns the corresponding analytics method */ function getAnalyticsMethod(methodType: MethodType) { - const windowAnalytics = (window as any).analytics; + const windowAnalytics = (window as any).rudderanalytics; if (!windowAnalytics) { return; } diff --git a/packages/govern-console/src/utils/TimeInterval.tsx b/packages/govern-console/src/utils/TimeInterval.tsx new file mode 100644 index 00000000..7627061e --- /dev/null +++ b/packages/govern-console/src/utils/TimeInterval.tsx @@ -0,0 +1,53 @@ +import { TIME_INTERVALS } from 'utils/constants'; +import { Interval } from 'utils/types'; + +function getIntervalObject(seconds: number, interval: number, index: number): Interval { + if (Math.floor(seconds % interval) !== 0) { + // revert to seconds + return { name: TIME_INTERVALS.names[0], value: seconds, index: 0 }; + } + return { + name: TIME_INTERVALS.names[index], + value: Math.floor(seconds / interval), + index: index, + }; +} + +/** + * getInterval tries to convert seconds to an aproximate type of Interval + * following the breakpoints of: + * -less then 1 minute - show seconds + * -less then 1 hour - show minutes + * -less then 1 day - show hours + * -more than 1 day - show days + * if not exact amounts or miltiplies of the above breakpoints reached + * then it revert back to seconds + * + * @param {number} seconds time in second + * @returns {Interval} + */ +function getInterval(seconds: number): Interval | undefined { + const intervals = TIME_INTERVALS.values; + let determined = false; + let index = intervals.length - 1; + + while (!determined) { + if (seconds >= intervals[intervals.length - 1]) { + determined = true; + return getIntervalObject(seconds, intervals[intervals.length - 1], intervals.length - 1); + } + + // find range + if (seconds < intervals[index] && seconds >= intervals[index - 1]) { + determined = true; + return getIntervalObject(seconds, intervals[index - 1], index - 1); + } + + index--; + if (index === 0) { + break; + } + } +} + +export default getInterval; diff --git a/packages/govern-console/src/utils/constants.tsx b/packages/govern-console/src/utils/constants.tsx index d8243f43..e7ed258a 100644 --- a/packages/govern-console/src/utils/constants.tsx +++ b/packages/govern-console/src/utils/constants.tsx @@ -7,3 +7,8 @@ export const ETHERSCAN_API_KEY = 'HS2AR94Q6G6RYIYHR7VRCZGP6E382K4BDC '; export const IPFS_GATEWAY = 'https://ipfs.io/ipfs/'; export const ARAGON_HELP_URL = 'https://help.aragon.org/'; export const MAX_SCHEDULE_ACCESS_LIST_ALLOWED = 10; + +export const TIME_INTERVALS = { + names: ['Seconds', 'Minutes', 'Hours', 'Days'], + values: [1, 60, 3600, 86400], +}; diff --git a/packages/govern-console/src/utils/types.tsx b/packages/govern-console/src/utils/types.tsx index ed5d7db5..d80b218b 100644 --- a/packages/govern-console/src/utils/types.tsx +++ b/packages/govern-console/src/utils/types.tsx @@ -87,3 +87,9 @@ export type ActionBuilderState = | 'chooseAction' | 'abiForm' | 'chooseFunctions'; + +export interface Interval { + name: string; + value: number; + index: number; +} diff --git a/yarn.lock b/yarn.lock index 93be225c..d2cbc31e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -86,7 +86,7 @@ "@aragon/ui@https://github.com/aragon/ui.git#v2": version "1.7.0" - resolved "https://github.com/aragon/ui.git#3626256dfdeb0ee0a2440b79952dff5aa671c37e" + resolved "https://github.com/aragon/ui.git#058c49838a9e11e93031714cbb77dc0aefb637f9" dependencies: "@babel/runtime" "^7.3.1" airbnb-prop-types "^2.9.0"