@@ -597,22 +597,22 @@ export class EnclavedExpressClient {
597597 }
598598 }
599599
600- /**
601- * Create custom MPCv2 Round 1 signing function for enclaved express client
602- */
603- export function signMPCv2Round1 (
604- enclavedExpressClient : EnclavedExpressClient ,
605- source : 'user' | 'backup' ,
606- pub : string ,
607- ) : ( params : SignMpcV2Round1Params ) => Promise < SignMpcV2Round1Response > {
608- return async function ( params ) : Promise < SignMpcV2Round1Response > {
609- if ( ! enclavedExpressClient [ 'coin' ] ) {
600+ /**
601+ * Sign MPCv2 Round 1
602+ */
603+ async signMPCv2Round1 (
604+ enclavedExpressClient : EnclavedExpressClient ,
605+ source : 'user' | 'backup' ,
606+ pub : string ,
607+ params : SignMpcV2Round1Params ,
608+ ) : Promise < SignMpcV2Round1Response > {
609+ if ( ! this [ 'coin' ] ) {
610610 throw new Error ( 'Coin must be specified to sign an MPCv2 Round 1' ) ;
611611 }
612612
613613 try {
614- let request = enclavedExpressClient [ 'apiClient' ] [ 'v1.mpc.sign' ] . post ( {
615- coin : enclavedExpressClient [ 'coin' ] ,
614+ let request = this [ 'apiClient' ] [ 'v1.mpc.sign' ] . post ( {
615+ coin : this [ 'coin' ] ,
616616 shareType : 'mpcv2round1' ,
617617 ...params ,
618618 source,
@@ -629,33 +629,32 @@ export function signMPCv2Round1(
629629 debugLogger ( 'Failed to sign mpcv2 round 1: %s' , err . message ) ;
630630 throw err ;
631631 }
632- } ;
633- }
632+ }
634633
635- /**
636- * Create custom MPCv2 Round 2 signing function for enclaved express client
637- */
638- export function signMPCv2Round2 (
639- enclavedExpressClient : EnclavedExpressClient ,
640- source : 'user' | 'backup' ,
641- pub : string ,
642- ) : ( params : SignMpcV2Round2Params ) => Promise < SignMpcV2Round2Response > {
643- return async function ( params ) : Promise < SignMpcV2Round2Response > {
644- if ( ! enclavedExpressClient [ 'coin' ] ) {
634+ /**
635+ * Sign MPCv2 Round 2
636+ */
637+ async signMPCv2Round2 (
638+ enclavedExpressClient : EnclavedExpressClient ,
639+ source : 'user' | 'backup' ,
640+ pub : string ,
641+ params : SignMpcV2Round2Params ,
642+ ) : Promise < SignMpcV2Round2Response > {
643+ if ( ! this [ 'coin' ] ) {
645644 throw new Error ( 'Coin must be specified to sign an MPCv2 Round 2' ) ;
646645 }
647646
648647 try {
649- let request = enclavedExpressClient [ 'apiClient' ] [ 'v1.mpc.sign' ] . post ( {
650- coin : enclavedExpressClient [ 'coin' ] ,
648+ let request = this [ 'apiClient' ] [ 'v1.mpc.sign' ] . post ( {
649+ coin : this [ 'coin' ] ,
651650 shareType : 'mpcv2round2' ,
652651 ...params ,
653652 source,
654653 pub,
655654 } ) ;
656655
657- if ( enclavedExpressClient [ 'tlsMode' ] === TlsMode . MTLS ) {
658- request = request . agent ( enclavedExpressClient [ 'createHttpsAgent' ] ( ) ) ;
656+ if ( this [ 'tlsMode' ] === TlsMode . MTLS ) {
657+ request = request . agent ( this [ 'createHttpsAgent' ] ( ) ) ;
659658 }
660659 const response = await request . decodeExpecting ( 200 ) ;
661660 return response . body ;
@@ -664,33 +663,32 @@ export function signMPCv2Round2(
664663 debugLogger ( 'Failed to sign mpcv2 round 2: %s' , err . message ) ;
665664 throw err ;
666665 }
667- } ;
668- }
666+ }
669667
670- /**
671- * Create custom MPCv2 Round 3 signing function for enclaved express client
672- */
673- export function signMPCv2Round3 (
674- enclavedExpressClient : EnclavedExpressClient ,
675- source : 'user' | 'backup' ,
676- pub : string ,
677- ) : ( params : SignMpcV2Round3Params ) => Promise < SignMpcV2Round3Response > {
678- return async function ( params ) : Promise < SignMpcV2Round3Response > {
679- if ( ! enclavedExpressClient [ 'coin' ] ) {
668+ /**
669+ * Sign MPCv2 Round 3
670+ */
671+ async signMPCv2Round3 (
672+ enclavedExpressClient : EnclavedExpressClient ,
673+ source : 'user' | 'backup' ,
674+ pub : string ,
675+ params : SignMpcV2Round3Params ,
676+ ) : Promise < SignMpcV2Round3Response > {
677+ if ( ! this [ 'coin' ] ) {
680678 throw new Error ( 'Coin must be specified to sign an MPCv2 Round 3' ) ;
681679 }
682680
683681 try {
684- let request = enclavedExpressClient [ 'apiClient' ] [ 'v1.mpc.sign' ] . post ( {
685- coin : enclavedExpressClient [ 'coin' ] ,
682+ let request = this [ 'apiClient' ] [ 'v1.mpc.sign' ] . post ( {
683+ coin : this [ 'coin' ] ,
686684 shareType : 'mpcv2round3' ,
687685 ...params ,
688686 source,
689687 pub,
690688 } ) ;
691689
692- if ( enclavedExpressClient [ 'tlsMode' ] === TlsMode . MTLS ) {
693- request = request . agent ( enclavedExpressClient [ 'createHttpsAgent' ] ( ) ) ;
690+ if ( this [ 'tlsMode' ] === TlsMode . MTLS ) {
691+ request = request . agent ( this [ 'createHttpsAgent' ] ( ) ) ;
694692 }
695693 const response = await request . decodeExpecting ( 200 ) ;
696694 return response . body ;
@@ -699,7 +697,7 @@ export function signMPCv2Round3(
699697 debugLogger ( 'Failed to sign mpcv2 round 3: %s' , err . message ) ;
700698 throw err ;
701699 }
702- } ;
700+ }
703701}
704702
705703/**
0 commit comments