@@ -599,30 +599,29 @@ export class EnclavedExpressClient {
599599 }
600600 }
601601
602- /**
603- * Create custom MPCv2 Round 1 signing function for enclaved express client
604- */
605- export function signMPCv2Round1 (
606- enclavedExpressClient : EnclavedExpressClient ,
607- source : 'user' | 'backup' ,
608- pub : string ,
609- ) : ( params : SignMpcV2Round1Params ) => Promise < SignMpcV2Round1Response > {
610- return async function ( params ) : Promise < SignMpcV2Round1Response > {
611- if ( ! enclavedExpressClient [ 'coin' ] ) {
602+ /**
603+ * Sign MPCv2 Round 1
604+ */
605+ async signMPCv2Round1 (
606+ source : 'user' | 'backup' ,
607+ pub : string ,
608+ params : SignMpcV2Round1Params ,
609+ ) : Promise < SignMpcV2Round1Response > {
610+ if ( ! this [ 'coin' ] ) {
612611 throw new Error ( 'Coin must be specified to sign an MPCv2 Round 1' ) ;
613612 }
614613
615614 try {
616- let request = enclavedExpressClient [ 'apiClient' ] [ 'v1.mpc.sign' ] . post ( {
617- coin : enclavedExpressClient [ 'coin' ] ,
615+ let request = this [ 'apiClient' ] [ 'v1.mpc.sign' ] . post ( {
616+ coin : this [ 'coin' ] ,
618617 shareType : 'mpcv2round1' ,
619618 ...params ,
620619 source,
621620 pub,
622621 } ) ;
623622
624- if ( enclavedExpressClient [ 'tlsMode' ] === TlsMode . MTLS ) {
625- request = request . agent ( enclavedExpressClient [ 'createHttpsAgent' ] ( ) ) ;
623+ if ( this [ 'tlsMode' ] === TlsMode . MTLS ) {
624+ request = request . agent ( this [ 'createHttpsAgent' ] ( ) ) ;
626625 }
627626 const response = await request . decodeExpecting ( 200 ) ;
628627 return response . body ;
@@ -631,33 +630,31 @@ export function signMPCv2Round1(
631630 debugLogger ( 'Failed to sign mpcv2 round 1: %s' , err . message ) ;
632631 throw err ;
633632 }
634- } ;
635- }
633+ }
636634
637- /**
638- * Create custom MPCv2 Round 2 signing function for enclaved express client
639- */
640- export function signMPCv2Round2 (
641- enclavedExpressClient : EnclavedExpressClient ,
642- source : 'user' | 'backup' ,
643- pub : string ,
644- ) : ( params : SignMpcV2Round2Params ) => Promise < SignMpcV2Round2Response > {
645- return async function ( params ) : Promise < SignMpcV2Round2Response > {
646- if ( ! enclavedExpressClient [ 'coin' ] ) {
635+ /**
636+ * Sign MPCv2 Round 2
637+ */
638+ async signMPCv2Round2 (
639+ source : 'user' | 'backup' ,
640+ pub : string ,
641+ params : SignMpcV2Round2Params ,
642+ ) : Promise < SignMpcV2Round2Response > {
643+ if ( ! this [ 'coin' ] ) {
647644 throw new Error ( 'Coin must be specified to sign an MPCv2 Round 2' ) ;
648645 }
649646
650647 try {
651- let request = enclavedExpressClient [ 'apiClient' ] [ 'v1.mpc.sign' ] . post ( {
652- coin : enclavedExpressClient [ 'coin' ] ,
648+ let request = this [ 'apiClient' ] [ 'v1.mpc.sign' ] . post ( {
649+ coin : this [ 'coin' ] ,
653650 shareType : 'mpcv2round2' ,
654651 ...params ,
655652 source,
656653 pub,
657654 } ) ;
658655
659- if ( enclavedExpressClient [ 'tlsMode' ] === TlsMode . MTLS ) {
660- request = request . agent ( enclavedExpressClient [ 'createHttpsAgent' ] ( ) ) ;
656+ if ( this [ 'tlsMode' ] === TlsMode . MTLS ) {
657+ request = request . agent ( this [ 'createHttpsAgent' ] ( ) ) ;
661658 }
662659 const response = await request . decodeExpecting ( 200 ) ;
663660 return response . body ;
@@ -666,33 +663,31 @@ export function signMPCv2Round2(
666663 debugLogger ( 'Failed to sign mpcv2 round 2: %s' , err . message ) ;
667664 throw err ;
668665 }
669- } ;
670- }
666+ }
671667
672- /**
673- * Create custom MPCv2 Round 3 signing function for enclaved express client
674- */
675- export function signMPCv2Round3 (
676- enclavedExpressClient : EnclavedExpressClient ,
677- source : 'user' | 'backup' ,
678- pub : string ,
679- ) : ( params : SignMpcV2Round3Params ) => Promise < SignMpcV2Round3Response > {
680- return async function ( params ) : Promise < SignMpcV2Round3Response > {
681- if ( ! enclavedExpressClient [ 'coin' ] ) {
668+ /**
669+ * Sign MPCv2 Round 3
670+ */
671+ async signMPCv2Round3 (
672+ source : 'user' | 'backup' ,
673+ pub : string ,
674+ params : SignMpcV2Round3Params ,
675+ ) : Promise < SignMpcV2Round3Response > {
676+ if ( ! this [ 'coin' ] ) {
682677 throw new Error ( 'Coin must be specified to sign an MPCv2 Round 3' ) ;
683678 }
684679
685680 try {
686- let request = enclavedExpressClient [ 'apiClient' ] [ 'v1.mpc.sign' ] . post ( {
687- coin : enclavedExpressClient [ 'coin' ] ,
681+ let request = this [ 'apiClient' ] [ 'v1.mpc.sign' ] . post ( {
682+ coin : this [ 'coin' ] ,
688683 shareType : 'mpcv2round3' ,
689684 ...params ,
690685 source,
691686 pub,
692687 } ) ;
693688
694- if ( enclavedExpressClient [ 'tlsMode' ] === TlsMode . MTLS ) {
695- request = request . agent ( enclavedExpressClient [ 'createHttpsAgent' ] ( ) ) ;
689+ if ( this [ 'tlsMode' ] === TlsMode . MTLS ) {
690+ request = request . agent ( this [ 'createHttpsAgent' ] ( ) ) ;
696691 }
697692 const response = await request . decodeExpecting ( 200 ) ;
698693 return response . body ;
@@ -701,7 +696,7 @@ export function signMPCv2Round3(
701696 debugLogger ( 'Failed to sign mpcv2 round 3: %s' , err . message ) ;
702697 throw err ;
703698 }
704- } ;
699+ }
705700}
706701
707702/**
0 commit comments