Skip to content

Commit cdcd6f0

Browse files
authored
feat: simplify configuration of Signed Orders and Fills before signing (#140)
* feat: reduce required configuration fns for SignedFills * update error behavior
1 parent a57a150 commit cdcd6f0

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ members = ["crates/*"]
33
resolver = "2"
44

55
[workspace.package]
6-
version = "0.14.0"
6+
version = "0.14.1"
77
edition = "2021"
88
rust-version = "1.85"
99
authors = ["init4"]

crates/types/src/signing/error.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ pub enum SigningError {
2424
MissingChainId,
2525
/// Missing rollup chain id for a Fill.
2626
#[error(
27-
"Rollup chain id is missing. Populate it by calling with_ru_chain_id before attempting to sign"
27+
"Rollup chain id is missing. Populate it by calling with_chain before attempting to sign"
2828
)]
29+
#[deprecated(since = "0.14.1", note = "Use MissingChainId instead.")]
2930
MissingRollupChainId,
3031
/// Missing chain config for a specific chain.
3132
#[error("Target Order contract address is missing for chain id {0}. Populate it by calling with_chain before attempting to sign")]

crates/types/src/signing/fill.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ impl From<&SignedFill> for FillPermit2 {
117117
/// or [`AggregateOrders`] into a [`SignedFill`] with correct permit2 semantics.
118118
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
119119
pub struct UnsignedFill<'a> {
120-
/// The rollup chain id from which the Orders originated.
120+
/// The rollup chain id from which the Orders originated
121+
/// to which the Fill will be credited.
121122
ru_chain_id: Option<u64>,
122123
/// The set of Orders to fill. Multiple Orders can be aggregated into a single Fill,
123124
/// but they MUST all originate on the same rollup chain indicated by `ru_chain_id`.
@@ -215,18 +216,18 @@ impl<'a> UnsignedFill<'a> {
215216
}
216217

217218
/// Add the rollup chain id to the UnsignedFill.
218-
/// This is the rollup chain id from which the Orders originated,
219-
/// to which the Fill should be credited.
220-
/// MUST call this before signing, cannot be inferred.
219+
#[deprecated(since = "0.14.1", note = "Use `with_chain` instead.")]
221220
pub fn with_ru_chain_id(self, ru_chain_id: u64) -> Self {
222221
Self { ru_chain_id: Some(ru_chain_id), ..self }
223222
}
224223

225-
/// Add the chain id and Order contract address to the UnsignedFill.
224+
/// Add the chain ids and Orders contract addresses
225+
/// used for signing the Fill.
226+
/// MUST call before `sign` or `sign_for`.
226227
pub fn with_chain(mut self, constants: SignetSystemConstants) -> Self {
227228
self.target_chains.insert(constants.ru_chain_id(), constants.ru_orders());
228229
self.target_chains.insert(constants.host_chain_id(), constants.host_orders());
229-
self
230+
Self { ru_chain_id: Some(constants.ru_chain_id()), ..self }
230231
}
231232

232233
/// Sign the UnsignedFill, generating a SignedFill for each target chain.
@@ -270,7 +271,7 @@ impl<'a> UnsignedFill<'a> {
270271
.ok_or(SigningError::MissingOrderContract(target_chain_id))?;
271272

272273
// get the rollup chain id, or throw an error if not set
273-
let ru_chain_id = self.ru_chain_id.ok_or(SigningError::MissingRollupChainId)?;
274+
let ru_chain_id = self.ru_chain_id.ok_or(SigningError::MissingChainId)?;
274275

275276
// get the outputs for the target chain from the AggregateOrders
276277
let outputs = self.orders.outputs_for(target_chain_id, ru_chain_id);

crates/types/src/signing/order.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ impl<'a> UnsignedOrder<'a> {
192192
}
193193

194194
/// Add the chain id and Order contract address to the UnsignedOrder.
195+
/// MUST call before `sign`.
195196
pub fn with_chain(self, constants: &SignetSystemConstants) -> Self {
196197
Self {
197198
rollup_chain_id: Some(constants.ru_chain_id()),

0 commit comments

Comments
 (0)