Skip to content

[Feature] Generate enum that represents the selectors of a call #1031

@mattsse

Description

@mattsse

Component

sol! macro

Describe the feature you would like

we generate a list of all selectors:

/// All the selectors of this enum.
///
/// Note that the selectors might not be in the same order as the variants.
/// No guarantees are made about the order of the selectors.
///
/// Prefer using `SolInterface` methods instead.
// NOTE: This is currently sorted to allow for binary search in `SolInterface`.
pub const SELECTORS: &'static [#selector_type] = &[#(#selectors),*];

it would be nice to have an enum representation for those as well, that match to the functions, similar to functions

let functions_enum = (!functions.is_empty()).then(|| {
let mut attrs = enum_attrs;
let doc_str = format!("Container for all the [`{name}`](self) function calls.");
attrs.push(parse_quote!(#[doc = #doc_str]));
attrs.push(parse_quote!(#[derive(Clone)]));
let enum_expander = CallLikeExpander { cx, contract_name: name.clone(), extra_methods };
enum_expander.expand(ToExpand::Functions(&functions), attrs)
});

TODO

  • generate a selector enum that supports try_from[u8; 4] etc..

maybe @frankudoags ?

Additional context

No response

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions