@@ -31,10 +31,10 @@ import { Contract } from './Contract.js';
3131import { DebugResults , debugTemplate } from './debugging.js' ;
3232import {
3333 HashType ,
34+ isContractUnlocker ,
3435 isP2PKHUnlocker ,
3536 isStandardUnlockableUtxo ,
3637 isUnlockableUtxo ,
37- isUtxoP2PKH ,
3838 LibauthTokenDetails ,
3939 Output ,
4040 SignatureAlgorithm ,
@@ -280,6 +280,7 @@ export const generateTemplateScenarios = (
280280 const encodedConstructorArgs = contract . encodedConstructorArgs ;
281281 const scenarioIdentifier = `${ artifact . contractName } _${ abiFunction . name } _input${ inputIndex } _evaluate` ;
282282
283+ // TODO: Update scenario descriptions
283284 const scenarios = {
284285 // single scenario to spend out transaction under test given the CashScript parameters provided
285286 [ scenarioIdentifier ] : {
@@ -324,6 +325,7 @@ export const generateTemplateScenariosP2PKH = (
324325
325326 const { signature, publicKey } = getSignatureAndPubkeyFromP2PKHInput ( libauthTransaction . inputs [ inputIndex ] ) ;
326327
328+ // TODO: Update scenario descriptions
327329 const scenarios = {
328330 // single scenario to spend out transaction under test given the CashScript parameters provided
329331 [ scenarioIdentifier ] : {
@@ -459,20 +461,14 @@ export const getLibauthTemplates = (
459461
460462 // We can typecast this because we check that all inputs are standard unlockable at the top of this function
461463 for ( const [ inputIndex , input ] of ( txn . inputs as StandardUnlockableUtxo [ ] ) . entries ( ) ) {
462- // If template exists on the input, it indicates this is a P2PKH (Pay to Public Key Hash) input
463- if ( 'template' in input . unlocker ) {
464- // @ts -ignore TODO: Remove UtxoP2PKH type and only use UnlockableUtxo in Libauth Template generation
465- input . template = input . unlocker ?. template ; // Added to support P2PKH inputs in buildTemplate
464+ if ( isP2PKHUnlocker ( input . unlocker ) ) {
466465 Object . assign ( p2pkhEntities , generateTemplateEntitiesP2PKH ( inputIndex ) ) ;
467466 Object . assign ( p2pkhScripts , generateTemplateScriptsP2PKH ( inputIndex ) ) ;
468-
469- Object . assign ( scenarios , generateTemplateScenariosP2PKH ( libauthTransaction , csTransaction as any , inputIndex ) ) ;
470-
467+ Object . assign ( scenarios , generateTemplateScenariosP2PKH ( libauthTransaction , csTransaction , inputIndex ) ) ;
471468 continue ;
472469 }
473470
474- // If contract exists on the input, it indicates this is a contract input
475- if ( 'contract' in input . unlocker ) {
471+ if ( isContractUnlocker ( input . unlocker ) ) {
476472 const contract = input . unlocker ?. contract ;
477473 const abiFunction = input . unlocker ?. abiFunction ;
478474
@@ -807,23 +803,6 @@ export const generateTemplateScenarioBytecode = (
807803) : WalletTemplateScenarioBytecode | [ 'slot' ] => {
808804 if ( insertSlot ) return [ 'slot' ] ;
809805
810- const p2pkhScriptName = `${ p2pkhScriptNameTemplate } _${ inputIndex } ` ;
811-
812- // This is for P2PKH inputs in the old transaction builder (TODO: remove when we remove old transaction builder)
813- if ( isUtxoP2PKH ( input ) ) {
814- const { signature, publicKey } = getSignatureAndPubkeyFromP2PKHInput ( libauthInput ) ;
815-
816- return {
817- script : p2pkhScriptName ,
818- overrides : {
819- bytecode : {
820- [ `signature_${ inputIndex } ` ] : `0x${ binToHex ( signature ) } ` ,
821- [ `public_key_${ inputIndex } ` ] : `0x${ binToHex ( publicKey ) } ` ,
822- } ,
823- } ,
824- } ;
825- }
826-
827806 if ( isUnlockableUtxo ( input ) && isStandardUnlockableUtxo ( input ) ) {
828807 return generateUnlockingScriptParams ( input , libauthInput , p2pkhScriptNameTemplate , inputIndex ) ;
829808 }
0 commit comments