Skip to content

Commit

Permalink
Add finalization
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeykoren committed Dec 10, 2024
1 parent a4ba0f2 commit bf7a6ec
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/commands/test_orchard_zsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ impl Runnable for TestOrchardZSACmd {
let issuer = wallet.address_for_account(0, External);
let alice = wallet.address_for_account(1, External);

let asset_description = b"WETH".to_vec();
prepare_test(
config.chain.v6_activation_height,
&mut wallet,
Expand All @@ -36,7 +37,8 @@ impl Runnable for TestOrchardZSACmd {

// --------------------- Issue asset ---------------------

let issue_tx = create_issue_transaction(issuer, 1000, b"WETH".into(), &mut wallet);
let issue_tx =
create_issue_transaction(issuer, 1000, asset_description.clone(), &mut wallet);

let asset = issue_tx
.issue_bundle()
Expand Down Expand Up @@ -117,6 +119,26 @@ impl Runnable for TestOrchardZSACmd {
expected_delta,
&mut wallet,
);

// --------------------- Finalization ---------------------
// TODO - uncomment when finalization is implemented
// let finalization_tx = create_finalization_transaction(asset_description.clone(), &mut wallet);
// mine(
// &mut wallet,
// &mut rpc_client,
// Vec::from([finalization_tx]),
// false,
// );
//
// let invalid_issue_tx = create_issue_transaction(issuer, 2000, asset_description, &mut wallet);
// mine(
// &mut wallet,
// &mut rpc_client,
// Vec::from([invalid_issue_tx]),
// false,
// ); // TODO expect failure
//
// panic!("Invalid issue transaction was accepted");
}
}

Expand Down
11 changes: 11 additions & 0 deletions src/components/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,17 @@ pub fn create_issue_transaction(
build_tx(tx)
}

/// Create a transaction that issues a new asset
pub fn create_finalization_transaction(asset_desc: Vec<u8>, wallet: &mut Wallet) -> Transaction {
info!("Finalize asset");
let mut tx = create_tx(wallet);
tx.init_issuance_bundle::<FeeError>(wallet.issuance_key(), asset_desc.clone(), None)
.unwrap();
tx.finalize_asset::<FeeError>(asset_desc.as_slice())
.unwrap();
build_tx(tx)
}

/// Convert a block template and a list of transactions into a block proposal
pub fn template_into_proposal(
block_template: BlockTemplate,
Expand Down

0 comments on commit bf7a6ec

Please sign in to comment.