Skip to content

Commit

Permalink
Fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
azarovh committed Jun 25, 2024
1 parent 07d2dd2 commit 4f53e00
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 51 deletions.
6 changes: 3 additions & 3 deletions api-server/scanner-lib/src/blockchain_state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ async fn tx_fees<T: ApiServerStorageWrite>(
let pools = prefetch_pool_data(&inputs_utxos, db_tx).await?;
let pos_accounting_adapter = PoSAccountingAdapterToCheckFees { pools };

// TODO: support orders
// TODO(orders)
let orders_store = orders_accounting::InMemoryOrdersAccounting::new();
let orders_db = orders_accounting::OrdersAccountingDB::new(&orders_store);

Expand Down Expand Up @@ -1115,7 +1115,7 @@ async fn update_tables_from_transaction_inputs<T: ApiServerStorageWrite>(
.await;
}
AccountCommand::CancelOrder(_) | AccountCommand::FillOrder(_, _, _) => {
// TODO: support orders
// TODO(orders)
}
},
TxInput::Account(outpoint) => {
Expand Down Expand Up @@ -1682,7 +1682,7 @@ async fn update_tables_from_transaction_outputs<T: ApiServerStorageWrite>(
}
TxOutput::Htlc(_, _) => {} // TODO(HTLC)
TxOutput::AnyoneCanTake(_) => {
// TODO: support orders
// TODO(orders)
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions api-server/scanner-lib/src/sync/tests/simulation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ async fn simulation(
let mut delegations = BTreeSet::new();
let mut token_ids = BTreeSet::new();

// FIXME: proper impl
// TODO(orders)
let orders_store = orders_accounting::InMemoryOrdersAccounting::new();
let orders_db = orders_accounting::OrdersAccountingDB::new(&orders_store);

Expand Down Expand Up @@ -406,7 +406,7 @@ async fn simulation(
| TxOutput::LockThenTransfer(_, _, _)
| TxOutput::ProduceBlockFromStake(_, _)
| TxOutput::Htlc(_, _) => {}
TxOutput::AnyoneCanTake(_) => unimplemented!(), // TODO: support orders
TxOutput::AnyoneCanTake(_) => unimplemented!(), // TODO(orders)
});

tx.inputs().iter().for_each(|inp| match inp {
Expand Down Expand Up @@ -461,7 +461,7 @@ async fn simulation(
burn_coins(&mut statistics, token_change_authority_fee);
}
AccountCommand::CancelOrder(_) | AccountCommand::FillOrder(_, _, _) => {
unimplemented!() // TODO: support orders
unimplemented!() // TODO(orders)
}
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ fn create_order_constraints(#[case] seed: Seed) {
let give_amount = Amount::from_atoms(rng.gen_range(100..1000));
let token_id = TokenId::random_using(&mut rng);
let ask_amount = Amount::from_atoms(rng.gen_range(100..1000));
let order_data = OrderData::new(
let order_data = Box::new(OrderData::new(
Destination::AnyoneCanSpend,
OutputValue::TokenV1(token_id, ask_amount),
OutputValue::Coin(give_amount),
);
));

let orders_store = InMemoryOrdersAccounting::new();
let orders_db = OrdersAccountingDB::new(&orders_store);
Expand Down
6 changes: 3 additions & 3 deletions chainstate/test-framework/src/random_tx_maker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ impl<'a> RandomTxMaker<'a> {
// Transfer output is created intentionally besides order output to not waste utxo
// (e.g. single genesis output on issuance)
let outputs = vec![
TxOutput::AnyoneCanTake(order_data),
TxOutput::AnyoneCanTake(Box::new(order_data)),
TxOutput::Transfer(
OutputValue::Coin(change),
key_manager.new_destination(self.chainstate.get_chain_config(), rng),
Expand Down Expand Up @@ -1287,7 +1287,7 @@ impl<'a> RandomTxMaker<'a> {

let give_value = OutputValue::TokenV1(token_id, Amount::from_atoms(atoms));
let order_data = OrderData::new(Destination::AnyoneCanSpend, ask_value, give_value);
result_outputs.push(TxOutput::AnyoneCanTake(order_data));
result_outputs.push(TxOutput::AnyoneCanTake(Box::new(order_data)));
self.order_can_be_created = false;
} else {
// burn
Expand Down Expand Up @@ -1377,7 +1377,7 @@ impl<'a> RandomTxMaker<'a> {
}
TxOutput::AnyoneCanTake(data) => {
let order_id = make_order_id(inputs[0].utxo_outpoint().unwrap());
let _ = orders_cache.create_order(order_id, data.clone()).unwrap();
let _ = orders_cache.create_order(order_id, *data.clone()).unwrap();
Some(output)
}
})
Expand Down
40 changes: 20 additions & 20 deletions chainstate/test-suite/src/tests/orders_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ fn create_order_check_storage(#[case] seed: Seed) {
let order_id = make_order_id(&tokens_outpoint);
let tx = TransactionBuilder::new()
.add_input(tokens_outpoint.into(), InputWitness::NoSignature(None))
.add_output(TxOutput::AnyoneCanTake(order_data.clone()))
.add_output(TxOutput::AnyoneCanTake(Box::new(order_data.clone())))
.build();
tf.make_block_builder().add_transaction(tx).build_and_process(&mut rng).unwrap();

Expand Down Expand Up @@ -149,11 +149,11 @@ fn create_two_same_orders_in_tx(#[case] seed: Seed) {

let ask_amount = Amount::from_atoms(rng.gen_range(1u128..1000));
let give_amount = Amount::from_atoms(rng.gen_range(1u128..1000));
let order_data = OrderData::new(
let order_data = Box::new(OrderData::new(
Destination::AnyoneCanSpend,
OutputValue::Coin(ask_amount),
OutputValue::TokenV1(token_id, give_amount),
);
));

let order_id = make_order_id(&tokens_outpoint);
let tx = TransactionBuilder::new()
Expand Down Expand Up @@ -203,8 +203,8 @@ fn create_two_orders_same_tx(#[case] seed: Seed) {
let order_id = make_order_id(&tokens_outpoint);
let tx = TransactionBuilder::new()
.add_input(tokens_outpoint.into(), InputWitness::NoSignature(None))
.add_output(TxOutput::AnyoneCanTake(order_data_1))
.add_output(TxOutput::AnyoneCanTake(order_data_2))
.add_output(TxOutput::AnyoneCanTake(Box::new(order_data_1)))
.add_output(TxOutput::AnyoneCanTake(Box::new(order_data_2)))
.build();
let result = tf.make_block_builder().add_transaction(tx).build_and_process(&mut rng);

Expand Down Expand Up @@ -233,11 +233,11 @@ fn create_two_orders_same_block(#[case] seed: Seed) {

let ask_amount = Amount::from_atoms(rng.gen_range(1u128..1000));
let give_amount = Amount::from_atoms(rng.gen_range(1u128..1000));
let order_data = OrderData::new(
let order_data = Box::new(OrderData::new(
Destination::AnyoneCanSpend,
OutputValue::Coin(ask_amount),
OutputValue::TokenV1(token_id, give_amount),
);
));

let tx1 = TransactionBuilder::new()
.add_input(
Expand Down Expand Up @@ -293,7 +293,7 @@ fn create_order_check_currencies(#[case] seed: Seed) {
tokens_outpoint.clone().into(),
InputWitness::NoSignature(None),
)
.add_output(TxOutput::AnyoneCanTake(order_data))
.add_output(TxOutput::AnyoneCanTake(Box::new(order_data)))
.build();
let tx_id = tx.transaction().get_id();
let result = tf.make_block_builder().add_transaction(tx).build_and_process(&mut rng);
Expand Down Expand Up @@ -326,7 +326,7 @@ fn create_order_check_currencies(#[case] seed: Seed) {
tokens_outpoint.clone().into(),
InputWitness::NoSignature(None),
)
.add_output(TxOutput::AnyoneCanTake(order_data))
.add_output(TxOutput::AnyoneCanTake(Box::new(order_data)))
.build();
let tx_id = tx.transaction().get_id();
let result = tf.make_block_builder().add_transaction(tx).build_and_process(&mut rng);
Expand Down Expand Up @@ -357,7 +357,7 @@ fn create_order_check_currencies(#[case] seed: Seed) {
.add_transaction(
TransactionBuilder::new()
.add_input(tokens_outpoint.into(), InputWitness::NoSignature(None))
.add_output(TxOutput::AnyoneCanTake(order_data.clone()))
.add_output(TxOutput::AnyoneCanTake(Box::new(order_data)))
.build(),
)
.build_and_process(&mut rng)
Expand Down Expand Up @@ -392,7 +392,7 @@ fn create_order_tokens_for_tokens(#[case] seed: Seed) {
.add_transaction(
TransactionBuilder::new()
.add_input(tokens_outpoint_2.into(), InputWitness::NoSignature(None))
.add_output(TxOutput::AnyoneCanTake(order_data.clone()))
.add_output(TxOutput::AnyoneCanTake(Box::new(order_data)))
.build(),
)
.build_and_process(&mut rng)
Expand Down Expand Up @@ -421,7 +421,7 @@ fn cancel_order_check_storage(#[case] seed: Seed) {
let order_id = make_order_id(&tokens_outpoint);
let tx = TransactionBuilder::new()
.add_input(tokens_outpoint.into(), InputWitness::NoSignature(None))
.add_output(TxOutput::AnyoneCanTake(order_data.clone()))
.add_output(TxOutput::AnyoneCanTake(Box::new(order_data)))
.build();
tf.make_block_builder().add_transaction(tx).build_and_process(&mut rng).unwrap();

Expand Down Expand Up @@ -474,7 +474,7 @@ fn fill_order_check_storage(#[case] seed: Seed) {
let order_id = make_order_id(&tokens_outpoint);
let tx = TransactionBuilder::new()
.add_input(tokens_outpoint.into(), InputWitness::NoSignature(None))
.add_output(TxOutput::AnyoneCanTake(order_data.clone()))
.add_output(TxOutput::AnyoneCanTake(Box::new(order_data.clone())))
.build();
tf.make_block_builder().add_transaction(tx).build_and_process(&mut rng).unwrap();

Expand Down Expand Up @@ -584,7 +584,7 @@ fn fill_partially_then_cancel(#[case] seed: Seed) {
let order_id = make_order_id(&tokens_outpoint);
let tx = TransactionBuilder::new()
.add_input(tokens_outpoint.into(), InputWitness::NoSignature(None))
.add_output(TxOutput::AnyoneCanTake(order_data.clone()))
.add_output(TxOutput::AnyoneCanTake(Box::new(order_data)))
.build();
tf.make_block_builder().add_transaction(tx).build_and_process(&mut rng).unwrap();

Expand Down Expand Up @@ -673,7 +673,7 @@ fn cancel_order_check_signature(#[case] seed: Seed) {
let order_id = make_order_id(&tokens_outpoint);
let tx = TransactionBuilder::new()
.add_input(tokens_outpoint.into(), InputWitness::NoSignature(None))
.add_output(TxOutput::AnyoneCanTake(order_data.clone()))
.add_output(TxOutput::AnyoneCanTake(Box::new(order_data)))
.build();
tf.make_block_builder().add_transaction(tx).build_and_process(&mut rng).unwrap();

Expand Down Expand Up @@ -822,7 +822,7 @@ fn reorg_before_create(#[case] seed: Seed) {
let order_id = make_order_id(&tokens_outpoint);
let tx = TransactionBuilder::new()
.add_input(tokens_outpoint.into(), InputWitness::NoSignature(None))
.add_output(TxOutput::AnyoneCanTake(order_data.clone()))
.add_output(TxOutput::AnyoneCanTake(Box::new(order_data.clone())))
.build();
tf.make_block_builder().add_transaction(tx).build_and_process(&mut rng).unwrap();

Expand Down Expand Up @@ -910,7 +910,7 @@ fn reorg_after_create(#[case] seed: Seed) {
let order_id = make_order_id(&tokens_outpoint);
let tx = TransactionBuilder::new()
.add_input(tokens_outpoint.into(), InputWitness::NoSignature(None))
.add_output(TxOutput::AnyoneCanTake(order_data.clone()))
.add_output(TxOutput::AnyoneCanTake(Box::new(order_data.clone())))
// transfer output just to be able to spend something in alternative branch
.add_output(TxOutput::Transfer(
OutputValue::TokenV1(token_id, Amount::from_atoms(100)),
Expand Down Expand Up @@ -1045,11 +1045,11 @@ fn test_activation(#[case] seed: Seed) {

let (token_id, tokens_outpoint, _) = issue_and_mint_token_from_genesis(&mut rng, &mut tf);

let order_data = OrderData::new(
let order_data = Box::new(OrderData::new(
Destination::AnyoneCanSpend,
OutputValue::Coin(Amount::from_atoms(rng.gen_range(1u128..1000))),
OutputValue::TokenV1(token_id, Amount::from_atoms(rng.gen_range(1u128..1000))),
);
));

// Try to produce order output before activation, check an error
let tx = TransactionBuilder::new()
Expand Down Expand Up @@ -1083,7 +1083,7 @@ fn test_activation(#[case] seed: Seed) {
.add_transaction(
TransactionBuilder::new()
.add_input(tokens_outpoint.into(), InputWitness::NoSignature(None))
.add_output(TxOutput::AnyoneCanTake(order_data.clone()))
.add_output(TxOutput::AnyoneCanTake(order_data))
.build(),
)
.build_and_process(&mut rng)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,11 @@ pub fn data_deposit() -> TxOutput {
}

pub fn create_order() -> TxOutput {
TxOutput::AnyoneCanTake(OrderData::new(
TxOutput::AnyoneCanTake(Box::new(OrderData::new(
Destination::AnyoneCanSpend,
OutputValue::Coin(Amount::ZERO),
OutputValue::Coin(Amount::ZERO),
))
)))
}

pub fn issue_nft() -> TxOutput {
Expand Down
2 changes: 1 addition & 1 deletion chainstate/tx-verifier/src/transaction_verifier/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ where
let order_id = make_order_id(input_utxo_outpoint);
let result = self
.orders_accounting_cache
.create_order(order_id, order_data.clone())
.create_order(order_id, *order_data.clone())
.map_err(ConnectTransactionError::OrdersAccountingError);
Some(result)
}
Expand Down
2 changes: 1 addition & 1 deletion common/src/chain/transaction/output/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ pub enum TxOutput {
#[codec(index = 10)]
Htlc(OutputValue, Box<HashedTimelockContract>),
#[codec(index = 11)]
AnyoneCanTake(OrderData),
AnyoneCanTake(Box<OrderData>),
}

impl TxOutput {
Expand Down
2 changes: 1 addition & 1 deletion mintscript/src/tests/translate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ fn order0() -> (OrderId, OrderData) {
}

fn anyonecantake(data: OrderData) -> TestInputInfo {
tii(TxOutput::AnyoneCanTake(data))
tii(TxOutput::AnyoneCanTake(Box::new(data)))
}

fn account_spend(deleg: DelegationId, amount: u128) -> TestInputInfo {
Expand Down
4 changes: 2 additions & 2 deletions wallet/src/account/currency_grouper/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub(crate) fn group_outputs<T, Grouped: Clone>(
get_tx_output(&output).clone(),
)))
}
// TODO: support orders
// TODO(orders)
TxOutput::AnyoneCanTake(_) => unimplemented!(),
};

Expand Down Expand Up @@ -114,7 +114,7 @@ pub fn group_outputs_with_issuance_fee<T, Grouped: Clone>(
get_tx_output(&output).clone(),
)))
}
// TODO: support orders
// TODO(orders)
TxOutput::AnyoneCanTake(_) => unimplemented!(),
};

Expand Down
8 changes: 4 additions & 4 deletions wallet/src/account/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1347,7 +1347,7 @@ impl Account {
.token_data(token_id)
.map(|data| (None, Some(data.authority.clone())))
.ok_or(WalletError::UnknownTokenId(*token_id)),
// TODO: support orders
// TODO(orders)
AccountCommand::CancelOrder(_) => unimplemented!(),
AccountCommand::FillOrder(_, _, _) => unimplemented!(),
}
Expand Down Expand Up @@ -1828,7 +1828,7 @@ impl Account {
self.find_token(token_id).is_ok()
|| self.is_destination_mine_or_watched(address)
}
// TODO: support orders
// TODO(orders)
AccountCommand::CancelOrder(_) => unimplemented!(),
AccountCommand::FillOrder(_, _, _) => unimplemented!(),
},
Expand Down Expand Up @@ -2194,7 +2194,7 @@ fn group_preselected_inputs(
output.clone(),
)))
}
// TODO: support orders
// TODO(orders)
TxOutput::AnyoneCanTake(_) => unimplemented!(),
};
update_preselected_inputs(currency, value, *fee)?;
Expand Down Expand Up @@ -2239,7 +2239,7 @@ fn group_preselected_inputs(
.ok_or(WalletError::OutputAmountOverflow)?,
)?;
}
// TODO: support orders
// TODO(orders)
AccountCommand::CancelOrder(_) => unimplemented!(),
AccountCommand::FillOrder(_, _, _) => unimplemented!(),
},
Expand Down
Loading

0 comments on commit 4f53e00

Please sign in to comment.