@@ -58,7 +58,7 @@ export class MpcContract implements IMpcContract {
5858 this . connectedAccount = account ;
5959 this . rootPublicKey = rootPublicKey ;
6060
61- this . contract = new Contract ( account . connection , contractId , {
61+ this . contract = new Contract ( account . getConnection ( ) , contractId , {
6262 changeMethods : [ "sign" ] ,
6363 viewMethods : [ "public_key" , "experimental_signature_deposit" ] ,
6464 useLocalViewExecution : false ,
@@ -164,35 +164,16 @@ export class MpcContract implements IMpcContract {
164164 * @returns The execution outcome
165165 */
166166 async signAndSendSignRequest (
167- transaction : FunctionCallTransaction < { request : SignArgs } > ,
168- blockTimeout : number = 30
167+ transaction : FunctionCallTransaction < { request : SignArgs } >
169168 ) : Promise < FinalExecutionOutcome > {
170169 const account = this . connectedAccount ;
171- // @ts -expect-error: Account.signTransaction is protected (for no apparently good reason)
172- const [ txHash , signedTx ] = await account . signTransaction (
170+ const signedTx = await account . createSignedTransaction (
173171 this . contract . contractId ,
174172 transaction . actions . map ( ( { params : { args, gas, deposit } } ) =>
175173 transactions . functionCall ( "sign" , args , BigInt ( gas ) , BigInt ( deposit ) )
176174 )
177175 ) ;
178- const provider = account . connection . provider ;
179- let outcome = await provider . sendTransactionAsync ( signedTx ) ;
180-
181- let pings = 0 ;
182- while (
183- outcome . final_execution_status != "EXECUTED" &&
184- pings < blockTimeout
185- ) {
186- await new Promise ( ( resolve ) => setTimeout ( resolve , 1000 ) ) ;
187- outcome = await provider . txStatus ( txHash , account . accountId , "INCLUDED" ) ;
188- pings += 1 ;
189- }
190- if ( pings >= blockTimeout ) {
191- console . warn (
192- `Request status polling exited before desired outcome.\n Current status: ${ outcome . final_execution_status } \nSignature Request will likely fail.`
193- ) ;
194- }
195- return outcome ;
176+ return account . provider . sendTransactionUntil ( signedTx , "EXECUTED" ) ;
196177 }
197178}
198179
0 commit comments