Skip to content

Commit 00e526f

Browse files
committed
Fix selector_id!
1 parent 646d436 commit 00e526f

23 files changed

+37
-35
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
- Implement `bn128` precompiles ‒ [2708](https://github.com/use-ink/ink/pull/2718)
1111

1212
### Changed
13-
- Change `selector_bytes!` macro to accept `Abi` argument ‒ [2721](https://github.com/use-ink/ink/pull/2721)
13+
- Change `selector_bytes!` + `selector_id!` macro to accept `Abi` argument ‒ [2721](https://github.com/use-ink/ink/pull/2721)
1414
- Refactor contract ref generation and add automatic re-exporting ‒ [#2710](https://github.com/use-ink/ink/pull/2710)
1515
- Implement and stabilize `terminate_contract`[2708](https://github.com/use-ink/ink/pull/2708)
1616

crates/ink/ir/src/ir/selector.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,8 @@ mod tests {
325325
use quote::quote;
326326
let sel = SelectorMacro::<crate::marker::SelectorBytes>::try_from(quote! {
327327
Abi::Sol, "ownCodeHash()"
328-
}).unwrap();
328+
})
329+
.unwrap();
329330
assert_eq!(sel.selector.bytes, [219u8, 107, 220, 138]);
330331
}
331332

@@ -334,7 +335,8 @@ mod tests {
334335
use quote::quote;
335336
let sel = SelectorMacro::<crate::marker::SelectorBytes>::try_from(quote! {
336337
Abi::Ink, "flip"
337-
}).unwrap();
338+
})
339+
.unwrap();
338340
assert_eq!(sel.selector.bytes, hex_literal::hex!("633aa551"));
339341
}
340342
}

crates/ink/tests/ui/abi/all/pass/message-name-override.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ unsafe extern "Rust" {
2727
fn main() {
2828
// Message selector and selector id both use the name override.
2929
// `blake2b("myMessage")` == `0x6fdbfc04`
30-
const MESSAGE_ID: u32 = ::ink::selector_id!("myMessage");
30+
const MESSAGE_ID: u32 = ::ink::selector_id!(Abi::Ink, "myMessage");
3131
assert_eq!(
3232
<Contract as ::ink::reflect::DispatchableMessageInfo<MESSAGE_ID>>::SELECTOR,
3333
[0x6f, 0xdb, 0xfc, 0x04],

crates/ink/tests/ui/abi/all/pass/message-selector-encoding.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ mod contract {
5151

5252
fn main() {
5353
// ink! `message_0` trait definition
54-
const TRAIT_ID: u32 = ::ink::selector_id!("Messages::message_0");
54+
const TRAIT_ID: u32 = ::ink::selector_id!(Abi::Ink, "Messages::message_0");
5555
assert_eq!(
5656
<Contract as ::ink::reflect::DispatchableMessageInfo<TRAIT_ID>>::SELECTOR,
5757
[0xFB, 0xAB, 0x03, 0xCE],
@@ -85,7 +85,7 @@ fn main() {
8585
);
8686

8787
// ink! `message_3` inherent
88-
const INHERENT_ID: u32 = ::ink::selector_id!("message_3");
88+
const INHERENT_ID: u32 = ::ink::selector_id!(Abi::Ink, "message_3");
8989
assert_eq!(
9090
<Contract as ::ink::reflect::DispatchableMessageInfo<INHERENT_ID>>::SELECTOR,
9191
[0xB6, 0xC3, 0x27, 0x49],

crates/ink/tests/ui/abi/all/pass/trait-def-message-name-override.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fn main() {
2727
}
2828

2929
// ink! selector
30-
assert_selector_eq!(selector_id!("myMessage"), selector_bytes!(Abi::Ink, "TraitDefinition::myMessage"));
30+
assert_selector_eq!(selector_id!(Abi::Ink, "myMessage"), selector_bytes!(Abi::Ink, "TraitDefinition::myMessage"));
3131

3232
// `keccak256("myMessage()")` == `0x1b008a9f`
3333
assert_selector_eq!(0x1b008a9f_u32, [0x1b, 0x00, 0x8a, 0x9f]);

crates/ink/tests/ui/contract/pass/constructor/constructor-name-override.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ unsafe extern "Rust" {
2525
fn main() {
2626
// Constructor selector and selector id both use the name override.
2727
// `blake2b("myConstructor")` == `0xca295c67`
28-
const CTOR_ID: u32 = ::ink::selector_id!("myConstructor");
28+
const CTOR_ID: u32 = ::ink::selector_id!(Abi::Ink, "myConstructor");
2929
assert_eq!(
3030
<Contract as ::ink::reflect::DispatchableConstructorInfo<CTOR_ID>>::SELECTOR.unwrap(),
3131
[0xca, 0x29, 0x5c, 0x67],

crates/ink/tests/ui/contract/pass/constructor/constructor-return-result-alias.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fn main() {
2828
use contract::Contract;
2929
use std::any::TypeId;
3030

31-
const ID: u32 = ::ink::selector_id!("constructor");
31+
const ID: u32 = ::ink::selector_id!(Abi::Ink, "constructor");
3232
assert_eq!(
3333
<Contract as ::ink::reflect::DispatchableConstructorInfo<ID>>::IS_RESULT,
3434
true

crates/ink/tests/ui/contract/pass/constructor/constructor-return-result-err.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fn main() {
2626
use contract::Contract;
2727
use std::any::TypeId;
2828

29-
const ID: u32 = ::ink::selector_id!("constructor");
29+
const ID: u32 = ::ink::selector_id!(Abi::Ink, "constructor");
3030
assert_eq!(
3131
<Contract as ::ink::reflect::DispatchableConstructorInfo<ID>>::IS_RESULT,
3232
true

crates/ink/tests/ui/contract/pass/constructor/constructor-return-result-explicit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fn main() {
2626
use contract::Contract;
2727
use std::any::TypeId;
2828

29-
const ID: u32 = ::ink::selector_id!("constructor");
29+
const ID: u32 = ::ink::selector_id!(Abi::Ink, "constructor");
3030

3131
assert_eq!(
3232
<Contract as ::ink::reflect::DispatchableConstructorInfo<ID>>::IS_RESULT,

crates/ink/tests/ui/contract/pass/constructor/constructor-selector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ mod contract {
3030
}
3131

3232
fn main() {
33-
const ID: u32 = ::ink::selector_id!("constructor_0");
33+
const ID: u32 = ::ink::selector_id!(Abi::Ink, "constructor_0");
3434
assert_eq!(
3535
<Contract as ::ink::reflect::DispatchableConstructorInfo<ID>>::SELECTOR.unwrap(),
3636
selector_bytes!(Abi::Ink, "constructor_0")

0 commit comments

Comments
 (0)