Skip to content

Commit

Permalink
update: remove old util fn use bcs with derived
Browse files Browse the repository at this point in the history
  • Loading branch information
0xmovses committed Aug 19, 2024
1 parent 1b045a4 commit c2047f0
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions protocol-units/bridge/chains/movement/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,12 @@ impl BridgeContractCounterparty for MovementClient {
) -> BridgeContractCounterpartyResult<()> {
//@TODO properly return an error instead of unwrapping
let args = vec![
to_bcs_bytes(&initiator.0).unwrap(),
to_bcs_bytes(&bridge_transfer_id.0).unwrap(),
to_bcs_bytes(&hash_lock.0).unwrap(),
to_bcs_bytes(&time_lock.0).unwrap(),
to_bcs_bytes(&recipient.0).unwrap(),
to_bcs_bytes(&amount.0).unwrap(),
bcs::to_bytes(&initiator.0).unwrap(),
bcs::to_bytes(&bridge_transfer_id.0).unwrap(),
bcs::to_bytes(&hash_lock.0).unwrap(),
bcs::to_bytes(&time_lock.0).unwrap(),
bcs::to_bytes(&recipient.0).unwrap(),
bcs::to_bytes(&amount.0).unwrap(),
];
let payload = utils::make_aptos_payload(
self.counterparty_address,
Expand All @@ -251,9 +251,9 @@ impl BridgeContractCounterparty for MovementClient {
preimage: HashLockPreImage,
) -> BridgeContractCounterpartyResult<()> {
let args = vec![
to_bcs_bytes(&self.signer.address()).unwrap(),
to_bcs_bytes(&bridge_transfer_id.0).unwrap(),
to_bcs_bytes(&preimage.0).unwrap(),
bcs::to_bytes(&self.signer.address()).unwrap(),
bcs::to_bytes(&bridge_transfer_id.0).unwrap(),
bcs::to_bytes(&preimage.0).unwrap(),
];
let payload = utils::make_aptos_payload(
self.counterparty_address,
Expand All @@ -278,8 +278,8 @@ impl BridgeContractCounterparty for MovementClient {
bridge_transfer_id: BridgeTransferId<Self::Hash>,
) -> BridgeContractCounterpartyResult<()> {
let args = vec![
to_bcs_bytes(&self.signer.address()).unwrap(),
to_bcs_bytes(&bridge_transfer_id.0).unwrap(),
bcs::to_bytes(&self.signer.address()).unwrap(),
bcs::to_bytes(&bridge_transfer_id.0).unwrap(),
];
let payload = utils::make_aptos_payload(
self.counterparty_address,
Expand Down Expand Up @@ -317,10 +317,3 @@ impl MovementClient {
}
}
}

fn to_bcs_bytes<T>(value: &T) -> Result<Vec<u8>, anyhow::Error>
where
T: Serialize,
{
Ok(bcs::to_bytes(value)?)
}

0 comments on commit c2047f0

Please sign in to comment.