Skip to content

Commit a680ef3

Browse files
colll78keyan-m
andauthored
Introduce set_address (#370)
* Introduce set_address Implement `set_address` for the `TransactionOutput` enum type. * Update utils.rs * fix: formatting --------- Co-authored-by: keyanmaskoot <[email protected]>
1 parent 4528643 commit a680ef3

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

chain/rust/src/transaction/utils.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ impl TransactionOutput {
4848
}
4949
}
5050

51+
pub fn set_address(&mut self, new_address: Address) {
52+
match self {
53+
Self::AlonzoFormatTxOut(tx_out) => tx_out.address = new_address,
54+
Self::ConwayFormatTxOut(tx_out) => tx_out.address = new_address,
55+
}
56+
}
57+
5158
pub fn amount(&self) -> &Value {
5259
match self {
5360
Self::AlonzoFormatTxOut(tx_out) => &tx_out.amount,

chain/wasm/src/transaction/utils.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ impl TransactionOutput {
3131
self.0.address().clone().into()
3232
}
3333

34+
pub fn set_address(&mut self, addr: &Address) {
35+
self.0.set_address(addr.clone().into())
36+
}
37+
3438
pub fn amount(&self) -> Value {
3539
self.0.amount().clone().into()
3640
}

0 commit comments

Comments
 (0)