Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix serialization issues for Forest RPC untagged enums. #58

Open
Tracked by #23
elmattic opened this issue Oct 30, 2024 · 2 comments
Open
Tracked by #23

Fix serialization issues for Forest RPC untagged enums. #58

elmattic opened this issue Oct 30, 2024 · 2 comments
Assignees

Comments

@elmattic
Copy link
Contributor

elmattic commented Oct 30, 2024

Reproduce by using #57 and uncomment one of the EthGetBalance tests:

cargo run -q --bin cna-test-suite run src/test-suite/config.json.ignoreme
0	ChainHead with no authorization token	passed
1	EthAccounts with no authorization token	passed
2	EthAddressToFilecoinAddress with no authorization token	passed
3	EthBlockNumber with no authorization token	passed
4	EthChainId with no authorization token	passed
5	EthGasPrice with no authorization token	passed
6	EthGetBalance with no authorization token and subtype_2	failed
	0	err
	couldn't serialize params
	can only flatten structs and maps (got a string)
	1	src/test-suite/src/tests.rs:158:9
7	EthGetBalance with no authorization token and subtype_3	passed
8	EthGetBalance with no authorization token and subtype_4	passed
9	EthNewBlockFilter with no authorization token	passed
10	EthNewPendingTransactionFilter with no authorization token	passed
11	EthProtocolVersion with no authorization token	passed
12	EthSyncing with no authorization token	passed
failure 0 (EthGetBalance with no authorization token and subtype_2)
	0	err
	couldn't serialize params
	can only flatten structs and maps (got a string)
	1	src/test-suite/src/tests.rs:158:9
0 skipped, 12 succeeded, 1 failed
@elmattic
Copy link
Contributor Author

Maybe one approach would be to guide code generation to use an enum:

So instead of having:

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct BlockNumberOrHash {
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub subtype_0: Option<String>,
    ...
}

We would like:

#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(untagged)]
pub enum BlockNumberOrHash {
    Subtype0(String),
    ...
}

@elmattic elmattic moved this from New to In progress in Forest Backlog 🌲 Oct 30, 2024
@elmattic elmattic self-assigned this Oct 30, 2024
@elmattic
Copy link
Contributor Author

elmattic commented Dec 5, 2024

update: I've created an issue on the typify repository to ask if there's an easy workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In progress
Development

No branches or pull requests

1 participant