|
1 | 1 | use std::collections::HashSet;
|
2 | 2 |
|
3 |
| -use strum::{Display, EnumString}; |
| 3 | +use strum::{Display, EnumString, IntoStaticStr}; |
4 | 4 | use wasmer::wasmparser::ExternalKind;
|
5 | 5 |
|
6 | 6 | use crate::parsed_wasm::ParsedWasm;
|
7 | 7 |
|
8 | 8 | /// An enum containing all available contract entrypoints.
|
9 | 9 | /// This also provides conversions to and from strings.
|
10 |
| -#[derive(PartialEq, Eq, Debug, Clone, Copy, Hash, EnumString, Display)] |
| 10 | +#[derive(PartialEq, Eq, Debug, Clone, Copy, Hash, EnumString, Display, IntoStaticStr)] |
11 | 11 | pub enum Entrypoint {
|
12 | 12 | #[strum(serialize = "instantiate")]
|
13 | 13 | Instantiate,
|
@@ -35,13 +35,13 @@ pub enum Entrypoint {
|
35 | 35 | IbcPacketTimeout,
|
36 | 36 | }
|
37 | 37 |
|
38 |
| -pub const REQUIRED_IBC_EXPORTS: &[&str] = &[ |
39 |
| - "ibc_channel_open", |
40 |
| - "ibc_channel_connect", |
41 |
| - "ibc_channel_close", |
42 |
| - "ibc_packet_receive", |
43 |
| - "ibc_packet_ack", |
44 |
| - "ibc_packet_timeout", |
| 38 | +pub const REQUIRED_IBC_EXPORTS: &[Entrypoint] = &[ |
| 39 | + Entrypoint::IbcChannelOpen, |
| 40 | + Entrypoint::IbcChannelConnect, |
| 41 | + Entrypoint::IbcChannelClose, |
| 42 | + Entrypoint::IbcPacketReceive, |
| 43 | + Entrypoint::IbcPacketAck, |
| 44 | + Entrypoint::IbcPacketTimeout, |
45 | 45 | ];
|
46 | 46 |
|
47 | 47 | /// A trait that allows accessing shared functionality of `parity_wasm::elements::Module`
|
@@ -260,10 +260,15 @@ mod tests {
|
260 | 260 | }
|
261 | 261 |
|
262 | 262 | #[test]
|
263 |
| - fn entrypoint_display_works() { |
| 263 | + fn entrypoint_to_string_works() { |
264 | 264 | assert_eq!(
|
265 | 265 | Entrypoint::IbcPacketTimeout.to_string(),
|
266 | 266 | "ibc_packet_timeout".to_string()
|
267 | 267 | );
|
| 268 | + |
| 269 | + assert_eq!( |
| 270 | + <&'static str>::from(Entrypoint::IbcPacketReceive), |
| 271 | + "ibc_packet_receive" |
| 272 | + ); |
268 | 273 | }
|
269 | 274 | }
|
0 commit comments