ayazgv
1
Hello Dears!
How to represent tuple struct in a .did file like this:
#[derive(CandidType, Serialize, Deserialize)]
pub struct MyTupleStruct(pub Principal);
or is there any working way to generate a did file from rust code?
I’m asking again because the solutions described in the forum does not work for me
chenyan
2
Tuple is a shorthand for record, so record { type1; type2; type3 }
.
But the example you give is a newtype, the candid type is just principal
.
ayazgv
3
I did like that, dfx accepted it, just I’m not sure it will work or not. I didn’t try yet
type MyTupleStruct = record {
0: principal;
};
chenyan
4
It’s a newtype, so you need type MyTupleStruct = principal;
pub struct MyTupleStruct(pub Principal, pub Principal);
will map to record { principal; principal }
instead
2 Likes
ayazgv
5
Yep, I will try that, if my version will not work