import { tx , apdu , utils } from '@coolwallet/core' ; import * as scriptUtil from './utils/scriptUtil' ; import { signTxType , PROTOCOL } from './config/types' ; export default async function signTransaction ( signTxData , transfer , protocol ) { const { transaction , transport , appPrivateKey , appId , confirmCB , authorizedCB } = signTxData ; const preActions = [ ] ; const { script , argument } = await scriptUtil . getScriptAndArguments ( transaction , transfer , protocol ) ; const sendScript = async ( ) => { await apdu . tx . sendScript ( transport , script ) ; } ; preActions . push ( sendScript ) ; const sendArgument = async ( ) => { return apdu . tx . executeScript ( transport , appId , appPrivateKey , argument ) ; } ; const signature = await tx . flow . getSingleSignatureFromCoolWallet ( transport , preActions , sendArgument , true , confirmCB , authorizedCB , false ) ; await utils . checkSupportScripts ( transport ) ; return signature ; }