Skip to content

Commit 16de9a4

Browse files
authored
feat: continue transactions with request builder (#253)
* feat: transactions can be continued in builder * feat: signing payload can be requested from unsigned transactions Removes the need to import the prism_serde trait for encoding. * chore: Incorporate changes in zkvm elf
1 parent 9931422 commit 16de9a4

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

crates/common/src/builder.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ where
3535
pub fn to_modify_account(self, account: &Account) -> ModifyAccountRequestBuilder<'a, P> {
3636
ModifyAccountRequestBuilder::new(self.prism, account)
3737
}
38+
39+
pub fn continue_transaction(
40+
self,
41+
unsigned_transaction: UnsignedTransaction,
42+
) -> SigningTransactionRequestBuilder<'a, P> {
43+
SigningTransactionRequestBuilder::new(self.prism, unsigned_transaction)
44+
}
3845
}
3946

4047
impl<P> Default for RequestBuilder<'_, P>

crates/common/src/transaction.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub struct UnsignedTransaction {
2323
impl UnsignedTransaction {
2424
/// Signs the transaction with the given [`SigningKey`] and gives out a full [`Transaction`].
2525
pub fn sign(self, sk: &SigningKey) -> Result<Transaction, TransactionError> {
26-
let bytes = self.encode_to_bytes().map_err(|_| TransactionError::EncodingFailed)?;
26+
let bytes = self.signing_payload()?;
2727
let signature = sk.sign(&bytes);
2828

2929
Ok(Transaction {
@@ -47,6 +47,11 @@ impl UnsignedTransaction {
4747
vk: signature_bundle.verifying_key,
4848
}
4949
}
50+
51+
/// Returns the transaction's payload that needs to be signed, or a TransactionError if encoding fails.
52+
pub fn signing_payload(&self) -> Result<Vec<u8>, TransactionError> {
53+
self.encode_to_bytes().map_err(|_| TransactionError::EncodingFailed)
54+
}
5055
}
5156

5257
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq, ToSchema)]

elf/riscv32im-succinct-zkvm-elf

48 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)