Skip to content

Commit

Permalink
execute v1 with custom signature (#270)
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-stec authored Jan 31, 2025
1 parent 256b794 commit 0741ae5
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions openrpc-testgen/src/utils/v7/accounts/account/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,16 @@ where
self.prepare().await?.send().await
}

pub async fn send_with_custom_signature(
&self,
signature: Vec<Felt>,
) -> Result<AddInvokeTransactionResult<Felt>, AccountError<A::SignError>> {
self.prepare()
.await?
.send_with_custom_signature(signature)
.await
}

pub async fn prepare(&self) -> Result<PreparedExecutionV1<'a, A>, AccountError<A::SignError>> {
// Resolves nonce
let nonce = match self.nonce {
Expand Down Expand Up @@ -789,6 +799,22 @@ where
.map_err(AccountError::Provider)
}

pub async fn send_with_custom_signature(
&self,
signature: Vec<Felt>,
) -> Result<AddInvokeTransactionResult<Felt>, AccountError<A::SignError>> {
let tx_request = self
.get_invoke_request_with_custom_signature(signature)
.await
.map_err(AccountError::Signing)?;

self.account
.provider()
.add_invoke_transaction(BroadcastedTxn::Invoke(BroadcastedInvokeTxn::V1(tx_request)))
.await
.map_err(AccountError::Provider)
}

// The `simulate` function is temporarily removed until it's supported in [Provider]
// TODO: add `simulate` back once transaction simulation in supported

Expand All @@ -812,6 +838,19 @@ where
})
}

pub async fn get_invoke_request_with_custom_signature(
&self,
signature: Vec<Felt>,
) -> Result<InvokeTxnV1<Felt>, A::SignError> {
Ok(InvokeTxnV1 {
max_fee: self.inner.max_fee,
signature,
nonce: self.inner.nonce,
sender_address: self.account.address(),
calldata: self.account.encode_calls(&self.inner.calls),
})
}

pub async fn get_raw_execution(&self) -> &RawExecutionV1 {
&self.inner
}
Expand Down

0 comments on commit 0741ae5

Please sign in to comment.