@@ -756,7 +756,7 @@ export class FireblocksService {
756756 }
757757
758758 /**
759- * Sign and broadcast an ETH transaction with given integration using Fireblocks contract call feature
759+ * Sign an ETH transaction with given integration using Fireblocks raw signing
760760 */
761761 async signEthTx (
762762 integration : FireblocksIntegration ,
@@ -831,6 +831,61 @@ export class FireblocksService {
831831 return await fbSigner . signAndBroadcastWith ( payload , assetId , tx , integration . fireblocksDestinationId , true , fbNote ) ;
832832 }
833833
834+ /**
835+ * Sign a POL transaction with given integration using Fireblocks raw signing
836+ */
837+ async signPolTx (
838+ integration : FireblocksIntegration ,
839+ tx : components [ 'schemas' ] [ 'POLUnsignedTx' ] ,
840+ assetId : 'ETH_TEST5' | 'ETH' ,
841+ note ?: string ,
842+ ) : Promise < {
843+ signed_tx : { data : components [ 'schemas' ] [ 'POLSignedTx' ] } ;
844+ fireblocks_tx : TransactionResponse ;
845+ } > {
846+ const payload = {
847+ rawMessageData : {
848+ messages : [
849+ {
850+ content : tx . unsigned_tx_hash ,
851+ preHash : {
852+ content : tx . unsigned_tx_serialized ,
853+ hashAlgorithm : 'KECCAK256' ,
854+ } ,
855+ } ,
856+ ] ,
857+ } ,
858+ } ;
859+
860+ const fbSigner = this . getSigner ( integration ) ;
861+ const fbNote = note ? note : 'POL tx from @kilnfi/sdk' ;
862+ const fbTx = await fbSigner . sign ( payload , assetId , fbNote ) ;
863+
864+ const signature = fbTx ?. signedMessages ?. [ 0 ] ?. signature ;
865+
866+ if ( ! signature ) {
867+ throw new Error ( 'Fireblocks signature is missing' ) ;
868+ }
869+
870+ const preparedTx = await this . client . POST ( '/v1/pol/transaction/prepare' , {
871+ body : {
872+ unsigned_tx_serialized : tx . unsigned_tx_serialized ,
873+ r : `0x${ signature . r } ` ,
874+ s : `0x${ signature . s } ` ,
875+ v : signature . v ?? 0 ,
876+ } ,
877+ } ) ;
878+
879+ if ( preparedTx . error ) {
880+ throw new Error ( 'Failed to prepare transaction' ) ;
881+ }
882+
883+ return {
884+ signed_tx : preparedTx . data ,
885+ fireblocks_tx : fbTx ,
886+ } ;
887+ }
888+
834889 /**
835890 * Sign and broadcast a POL transaction with given integration using Fireblocks contract call feature
836891 */
0 commit comments