Skip to content

Commit

Permalink
impl unlock tx.
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanYuan committed Aug 27, 2024
1 parent ceaad59 commit fbd45e0
Show file tree
Hide file tree
Showing 7 changed files with 363 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl Aggregator {
}
None => {
let height = self.wait_for_transaction_packing(tx_hash.clone())?;
self.store.insert_branch_request(height.into(), tx_hash)?;
self.store.insert_branch_request(height, tx_hash)?;
self.store.clear_staged_tx()?;
}
}
Expand Down
19 changes: 18 additions & 1 deletion aggregator/aggregator-main/src/branch_to_rgbpp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,23 @@ impl Aggregator {
}
}
}

let unlock_tx = self.rgbpp_tx_builder.create_unlock_tx();
let unlock_tx = match unlock_tx {
Ok(unlock_tx) => unlock_tx,
Err(e) => {
error!("{}", e.to_string());
continue;
}
};
match wait_for_tx_confirmation(
self.rgbpp_rpc_client.clone(),
H256(unlock_tx.0),
Duration::from_secs(30),
) {
Ok(_) => {}
Err(e) => error!("{}", e.to_string()),
}
}
}

Expand Down Expand Up @@ -281,7 +298,7 @@ impl Aggregator {
let tx: Transaction = tx.into();
let witness = tx
.witnesses()
.get(0 as usize)
.get(0_usize)
.ok_or(Error::TransactionParseError(
"get witness error: None".to_string(),
))?;
Expand Down
2 changes: 2 additions & 0 deletions aggregator/aggregator-main/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(missing_docs)]

//! Branch Chain Aggregator
pub(crate) mod branch_to_rgbpp;
Expand Down
2 changes: 1 addition & 1 deletion aggregator/aggregator-main/src/rgbpp_to_branch/leap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl Aggregator {
let xudt = &self
.branch_scripts
.get(XUDT)
.ok_or(Error::BranchScriptNotFound(XUDT.to_string()))?
.ok_or(Error::ScriptNotFound(XUDT.to_string()))?
.script;
let owner_lock: Script = token_manager_cell.output.lock.clone().into();
let type_ = xudt
Expand Down
8 changes: 6 additions & 2 deletions aggregator/util/common/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,18 @@ pub enum Error {
RpcError(String),
#[error("timeout: {0}")]
TimedOut(String),
#[error("branch script not found: {0}")]
ScriptNotFound(String),
#[error("lock not found: {0}")]
LockNotFound(String),
#[error("branch script not found: {0}")]
BranchScriptNotFound(String),
#[error("asset type not found: {0}")]
AssetTypeNotFound(String),
#[error("database error: {0}")]
DatabaseError(String),
#[error("transaction not found: {0}")]
TransactionNotFound(String),
#[error("insufficient XUDT to unlock: {0}")]
InsufficientXUDTtoUnlock(String),
#[error("other error: {0}")]
Other(String),
}
Loading

0 comments on commit fbd45e0

Please sign in to comment.