In contract, I have
enum MyEnum {
Foo, Bar
}
and I want receive an instance of this in a public function (I have no idea which is the correct method signature)
public fun my_fun(e: MyEnum) { ... }
or
public fun my_fun(bs: vector<u8>) { ... }
In TypeScript, I can have a schema definition for this enum
const enumSchema = bcs.enum('MyEnum', {
a: null
b: null
};
Then what’s the correct way to put serialize {a: null} | {b: null} and use it as an argument in moveCall?
Any help is appreciated!
2 Likes
Did you ever find an answer for this? I’ve been looking around too and all I could find was a little snippet in discord:
Here is a snippet of a Sui move codbase
public enum Category has copy, drop, store {
A,
B,
C
}
public entry fun process_categories(categories: vector<Category>, ctx: &mut TxContext)
How can I call from a node js app using SUI TS SDK, to call the process_categories function, specifically send categories as an argument?
Enums are like objects and can’t be created in an SDK, they need to be created by a move function