Skip to content

Commit

Permalink
clipply issues
Browse files Browse the repository at this point in the history
  • Loading branch information
magecnion committed Jun 17, 2024
1 parent 6f0705b commit 01910a7
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 24 deletions.
6 changes: 3 additions & 3 deletions pallets/laos-evolution/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ impl TryFrom<u128> for Slot {
}
}

impl Into<u128> for Slot {
fn into(self) -> u128 {
self.as_u128()
impl From<Slot> for u128 {
fn from(slot: Slot) -> u128 {
slot.as_u128()
}
}

Expand Down
3 changes: 1 addition & 2 deletions precompile/evolution-collection-factory/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ where

fn convert_dispatch_error_to_string(err: DispatchError) -> String {
match err {
DispatchError::Module(mod_err) =>
mod_err.message.unwrap_or_else(|| "Unknown module error").into(),
DispatchError::Module(mod_err) => mod_err.message.unwrap_or("Unknown module error").into(),
_ => format!("{:?}", err),
}
}
Expand Down
8 changes: 4 additions & 4 deletions precompile/evolution-collection-factory/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fn create_collection_returns_address() {
Precompile1,
PrecompileCall::create_collection { owner: Address(Alice.into()) },
)
.execute_returns(Address(expected_collection_address.into()));
.execute_returns(Address(expected_collection_address));
})
}

Expand All @@ -87,7 +87,7 @@ fn create_collection_should_generate_log() {
Precompile1,
SELECTOR_LOG_NEW_COLLECTION,
Alice,
solidity::encode_event_data(Address(expected_collection_address.into())),
solidity::encode_event_data(Address(expected_collection_address)),
))
.execute_some();
});
Expand Down Expand Up @@ -118,7 +118,7 @@ fn create_collection_assign_collection_to_caller() {
Precompile1,
PrecompileCall::create_collection { owner: Address(Alice.into()) },
)
.execute_returns(Address(expected_collection_address.into()));
.execute_returns(Address(expected_collection_address));

assert_eq!(LaosEvolution::<Test>::collection_owner(0), Some(Alice.into()));
});
Expand All @@ -135,7 +135,7 @@ fn create_collection_inserts_bytecode_to_address() {
Precompile1,
PrecompileCall::create_collection { owner: Address(Alice.into()) },
)
.execute_returns(Address(expected_collection_address.into()));
.execute_returns(Address(expected_collection_address));

// Address is not empty
assert!(!Evm::<Test>::is_account_empty(&expected_collection_address));
Expand Down
2 changes: 1 addition & 1 deletion precompile/evolution-collection-legacy/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ fn mint(
token_uri: Vec<u8>,
) -> TokenId {
let owner: H160 = owner.into();
let slot: u128 = slot.0.try_into().unwrap();
let slot: u128 = slot.0.into();
let input = EvmDataWriter::new_with_selector(Action::Mint)
.write(Address(owner))
.write(U256::from(slot))
Expand Down
3 changes: 1 addition & 2 deletions precompile/evolution-collection/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,7 @@ where

fn convert_dispatch_error_to_string(err: DispatchError) -> String {
match err {
DispatchError::Module(mod_err) =>
mod_err.message.unwrap_or_else(|| "Unknown module error").into(),
DispatchError::Module(mod_err) => mod_err.message.unwrap_or("Unknown module error").into(),
_ => format!("{:?}", err),
}
}
Expand Down
18 changes: 6 additions & 12 deletions precompile/evolution-collection/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ fn mint(
);

handle.input =
PrecompileCall::mint { to: Address(owner.into()), slot, token_uri: token_uri.clone() }
.into();
PrecompileCall::mint { to: Address(owner), slot, token_uri: token_uri.clone() }.into();

let res = precompiles().execute(&mut handle).unwrap().unwrap();

Expand Down Expand Up @@ -149,11 +148,7 @@ fn mint_should_generate_log() {
.prepare_test(
Alice,
collection_address,
PrecompileCall::mint {
to: Address(owner.into()),
slot,
token_uri: token_uri.clone(),
},
PrecompileCall::mint { to: Address(owner), slot, token_uri: token_uri.clone() },
)
.expect_log(log2(
collection_address,
Expand Down Expand Up @@ -186,7 +181,7 @@ fn mint_asset_in_an_existing_collection_works() {
.prepare_test(
to,
collection_address,
PrecompileCall::mint { to: Address(to.into()), slot, token_uri: token_uri.clone() },
PrecompileCall::mint { to: Address(to), slot, token_uri: token_uri.clone() },
)
.execute_returns(expected_token_id);
});
Expand All @@ -206,7 +201,7 @@ fn when_mint_reverts_should_return_error() {
.prepare_test(
to,
collection_address,
PrecompileCall::mint { to: Address(to.into()), slot, token_uri },
PrecompileCall::mint { to: Address(to), slot, token_uri },
)
.execute_reverts(|r| r == b"AlreadyMinted");
});
Expand Down Expand Up @@ -234,8 +229,7 @@ fn token_uri_returns_the_result_from_source() {
let alice = H160::from_str(ALICE).unwrap();
let collection_address = create_collection(alice);
let token_uri: UnboundedString = "ciao".into();
let token_id =
mint(alice, collection_address, 0.try_into().unwrap(), token_uri.clone().into());
let token_id = mint(alice, collection_address, 0.try_into().unwrap(), token_uri.clone());

precompiles()
.prepare_test(alice, collection_address, PrecompileCall::token_uri { token_id })
Expand Down Expand Up @@ -453,7 +447,7 @@ fn expected_cost_mint_with_external_uri() {
owner,
collection_address,
PrecompileCall::mint {
to: Address(owner.into()),
to: Address(owner),
slot: 9.try_into().unwrap(),
token_uri: "ciao".into(),
},
Expand Down

0 comments on commit 01910a7

Please sign in to comment.