@@ -48,6 +48,8 @@ import { addressToLockScript, extendedStringify, getSignatureAndPubkeyFromP2PKHI
4848import { TransactionBuilder } from './TransactionBuilder.js' ;
4949import { deflate } from 'pako' ;
5050
51+ // TODO: Add / improve descriptions throughout the template generation
52+
5153export const getLibauthTemplates = (
5254 txn : TransactionBuilder ,
5355) : WalletTemplate => {
@@ -227,7 +229,6 @@ const generateTemplateEntitiesP2PKH = (
227229 const lockScriptName = `p2pkh_placeholder_lock_${ inputIndex } ` ;
228230 const unlockScriptName = `p2pkh_placeholder_unlock_${ inputIndex } ` ;
229231
230- // TODO: Add descriptions
231232 return {
232233 [ `signer_${ inputIndex } ` ] : {
233234 scripts : [ lockScriptName , unlockScriptName ] ,
@@ -411,7 +412,6 @@ const generateTemplateScenarios = (
411412 const encodedConstructorArgs = contract . encodedConstructorArgs ;
412413 const scenarioIdentifier = `${ artifact . contractName } _${ abiFunction . name } _input${ inputIndex } _evaluate` ;
413414
414- // TODO: Update scenario descriptions
415415 const scenarios = {
416416 // single scenario to spend out transaction under test given the CashScript parameters provided
417417 [ scenarioIdentifier ] : {
@@ -420,10 +420,10 @@ const generateTemplateScenarios = (
420420 data : {
421421 // encode values for the variables defined above in `entities` property
422422 bytecode : {
423+ ...generateTemplateScenarioParametersFunctionIndex ( abiFunction , contract . artifact . abi ) ,
423424 ...generateTemplateScenarioParametersValues ( abiFunction . inputs , encodedFunctionArgs ) ,
424425 ...generateTemplateScenarioParametersValues ( artifact . constructorInputs , encodedConstructorArgs ) ,
425426 } ,
426- // TODO: remove usage of private keys in P2SH scenarios as well
427427 keys : {
428428 privateKeys : generateTemplateScenarioKeys ( abiFunction . inputs , encodedFunctionArgs ) ,
429429 } ,
@@ -433,14 +433,6 @@ const generateTemplateScenarios = (
433433 } ,
434434 } ;
435435
436- // TODO: understand exactly what this does, and refactor
437- // Looks similar to code in generateTemplateScenarioParametersFunctionIndex
438- // Looks like we just want to use that function and spread in the scenarios data bytecode field
439- if ( artifact . abi . length > 1 ) {
440- const functionIndex = artifact . abi . findIndex ( ( func ) => func . name === abiFunction . name ) ;
441- scenarios ! [ scenarioIdentifier ] . data ! . bytecode ! . function_index = functionIndex . toString ( ) ;
442- }
443-
444436 return scenarios ;
445437} ;
446438
@@ -450,10 +442,8 @@ const generateTemplateScenariosP2PKH = (
450442 inputIndex : number ,
451443) : WalletTemplate [ 'scenarios' ] => {
452444 const scenarioIdentifier = `P2PKH_spend_input${ inputIndex } _evaluate` ;
453-
454445 const { signature, publicKey } = getSignatureAndPubkeyFromP2PKHInput ( libauthTransaction . inputs [ inputIndex ] ) ;
455446
456- // TODO: Update scenario descriptions
457447 const scenarios = {
458448 // single scenario to spend out transaction under test given the CashScript parameters provided
459449 [ scenarioIdentifier ] : {
@@ -609,7 +599,6 @@ const generateUnlockingScriptParams = (
609599 ...generateTemplateScenarioParametersValues ( abiFunction . inputs , encodedFunctionArgs ) ,
610600 ...generateTemplateScenarioParametersValues ( contract . artifact . constructorInputs , contract . encodedConstructorArgs ) ,
611601 } ,
612- // TODO: remove usage of private keys in P2SH scenarios as well
613602 keys : {
614603 privateKeys : generateTemplateScenarioKeys ( abiFunction . inputs , encodedFunctionArgs ) ,
615604 } ,
0 commit comments