File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -382,3 +382,31 @@ export const voteForProposalEstimateGas = async (type: "PARAMETER" | "OWNERSHIP"
382382export const voteForProposal = async ( type : "PARAMETER" | "OWNERSHIP" , id : number , support : boolean ) : Promise < string > => {
383383 return await _voteForProposal ( type , id , support , false ) as string ;
384384}
385+
386+ export const createEvmScript = async ( address : string , abi : any , action : any ) => {
387+ const agent = new Contract ( address , abi , curve . signer || curve . provider )
388+ console . log ( '1' )
389+ const zeroPad = ( num : string , places : number ) =>
390+ String ( num ) . padStart ( places , "0" ) ;
391+
392+ let evm_script = "0x00000001"
393+
394+ const contract = new Contract ( action . address , action . abi , curve . signer || curve . provider ) ;
395+ console . log ( '2' )
396+ const call_data = contract . interface . encodeFunctionData ( action . method , [ ...action . args ] )
397+ console . log ( call_data )
398+ console . log ( '3' )
399+ const agent_calldata = agent . interface
400+ . encodeFunctionData ( "execute" , [ action . address , 0 , call_data ] )
401+ . substring ( 2 ) ;
402+
403+ console . log ( '4' )
404+
405+ const length = zeroPad ( ( Math . floor ( agent_calldata . length ) / 2 ) . toString ( 16 ) , 8 ) ;
406+
407+ console . log ( '5' )
408+
409+ evm_script = `${ evm_script } ${ address . substring ( 2 ) } ${ length } ${ agent_calldata } ` ;
410+
411+ return evm_script
412+ }
Original file line number Diff line number Diff line change @@ -124,7 +124,7 @@ import {
124124 getProposal ,
125125 userProposalVotes ,
126126 voteForProposalEstimateGas ,
127- voteForProposal ,
127+ voteForProposal , createEvmScript ,
128128} from "./dao.js" ;
129129
130130async function init (
@@ -356,6 +356,7 @@ const curve = {
356356 userProposalVotes,
357357 // Transaction methods
358358 voteForProposal,
359+ createEvmScript,
359360
360361 estimateGas : {
361362 // --- CRV lock ---
You can’t perform that action at this time.
0 commit comments