44 submitManagingProposal,
55 processManagingProposal,
66} = require ( "../../../contracts/adapters/managing-adapter" ) ;
7+ const {
8+ bankAclFlags,
9+ } = require ( "../../../contracts/extensions/bank-extension" ) ;
710
811const { configs } = require ( "../../../../cli-config" ) ;
912const { daoAccessFlags } = require ( "../../../contracts/core/dao-registry" ) ;
@@ -23,34 +26,102 @@ const managingCommands = (program) => {
2326 )
2427 . description ( "Submit a new managing proposal." )
2528 . action ( async ( adapterName , adapterAddress , keys , values , data ) => {
26- await inquirer
27- . prompt ( [
28- {
29- type : "checkbox" ,
30- message : "Select the ACL Flags or hit ENTER to skip" ,
31- name : "aclFlags" ,
32- choices : daoAccessFlags . map ( ( f ) => Object . assign ( { name : f } ) ) ,
33- } ,
34- ] )
35- . then ( ( anwsers ) => {
36- notice ( `\n ::: Submitting Managing proposal...\n` ) ;
37- logEnvConfigs ( configs , configs . contracts . ManagingContract ) ;
38- info ( `Adapter:\t\t${ adapterName } @ ${ adapterAddress } ` ) ;
39- info ( `AccessFlags:\t\t${ JSON . stringify ( anwsers . aclFlags ) } ` ) ;
40- info ( `Keys:\t\t\t${ keys ? keys : "n/a" } ` ) ;
41- info ( `Values:\t\t\t${ values ? values : "n/a" } ` ) ;
42- info ( `Data:\t\t\t${ data ? data : "n/a" } \n` ) ;
29+ const { updateType } = await inquirer . prompt ( [
30+ {
31+ type : "list" ,
32+ message : "Which type of contract are you going to update?" ,
33+ name : "updateType" ,
34+ choices : [
35+ {
36+ name : "Adapter" ,
37+ value : 1 ,
38+ description : "If you want to Add/Remove/Update adapters" ,
39+ } ,
40+ {
41+ name : "Extension" ,
42+ value : 2 ,
43+ description : "If want to Add/Remove/Update extensions" ,
44+ } ,
45+ ] ,
46+ } ,
47+ ] ) ;
4348
44- return submitManagingProposal (
45- adapterName ,
46- adapterAddress ,
47- anwsers . aclFlags ,
48- keys ,
49- values ,
50- data ,
51- program . opts ( )
52- ) ;
53- } )
49+ const { daoAclFlags } = await inquirer . prompt ( [
50+ {
51+ type : "checkbox" ,
52+ message : "Select the **DAO** ACL Flags or hit ENTER to skip" ,
53+ name : "daoAclFlags" ,
54+ choices : daoAccessFlags . map ( ( f ) => Object . assign ( { name : f } ) ) ,
55+ } ,
56+ ] ) ;
57+
58+ const allExtensions = [
59+ {
60+ name : "Bank" ,
61+ id : "bank" ,
62+ aclFlags : bankAclFlags ,
63+ selectedFlags : [ ] ,
64+ } ,
65+ ] ;
66+
67+ const { requiredExtensions } = await inquirer . prompt ( [
68+ {
69+ type : "checkbox" ,
70+ message : "Does the adapter needs access to any of these extensions?" ,
71+ name : "requiredExtensions" ,
72+ choices : allExtensions ,
73+ } ,
74+ ] ) ;
75+
76+ const extensions = await requiredExtensions
77+ . flatMap ( ( name ) => allExtensions . filter ( ( ext ) => ext . name === name ) )
78+ . reduce ( async ( res , extension ) => {
79+ const { flags } = await inquirer . prompt ( [
80+ {
81+ type : "checkbox" ,
82+ message : `Select the **${ extension . name } ** ACL Flags or hit ENTER to skip` ,
83+ name : "flags" ,
84+ choices : extension . aclFlags . map ( ( f ) =>
85+ Object . assign ( { name : f } )
86+ ) ,
87+ } ,
88+ ] ) ;
89+ if ( flags && flags . length > 0 ) {
90+ res . push ( { ...extension , selectedFlags : flags } ) ;
91+ }
92+ return res ;
93+ } , [ ] ) ;
94+
95+ notice ( `\n ::: Submitting Managing proposal...\n` ) ;
96+ logEnvConfigs ( configs , configs . contracts . ManagingContract ) ;
97+ info ( `Adapter:\t\t${ adapterName } @ ${ adapterAddress } ` ) ;
98+ info ( `AccessFlags:\t\t${ JSON . stringify ( daoAclFlags ) } ` ) ;
99+ info ( `Keys:\t\t\t${ keys ? keys : "n/a" } ` ) ;
100+ info ( `Values:\t\t\t${ values ? values : "n/a" } ` ) ;
101+ info ( `Data:\t\t\t${ data ? data : "n/a" } ` ) ;
102+ info (
103+ `Extensions:\t\t${
104+ extensions
105+ ? JSON . stringify (
106+ extensions . map ( ( e ) =>
107+ Object . assign ( { [ e . name ] : e . selectedFlags } )
108+ )
109+ )
110+ : "n/a"
111+ } \n`
112+ ) ;
113+
114+ return submitManagingProposal (
115+ updateType ,
116+ adapterName ,
117+ adapterAddress ,
118+ daoAclFlags ,
119+ extensions ,
120+ keys ,
121+ values ,
122+ data ,
123+ program . opts ( )
124+ )
54125 . then ( ( data ) => {
55126 success ( `New Snapshot Proposal Id: ${ data . snapshotProposalId } \n` ) ;
56127 notice ( `::: Managing proposal submitted!\n` ) ;
0 commit comments