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

Provide support for solidity in serde_generate #61

Merged
merged 60 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
5839a44
First insertion of new code.
MathieuDutSik Dec 30, 2024
fb18128
First version of the code.
MathieuDutSik Jan 3, 2025
136dac9
Some correction for compilation.
MathieuDutSik Jan 3, 2025
1d4b9eb
Some additional corrections.
MathieuDutSik Jan 3, 2025
21d3ec1
Now it compiles, continuing the work.
MathieuDutSik Jan 3, 2025
72691b0
Further code insertion.
MathieuDutSik Jan 3, 2025
349e777
Further code write.
MathieuDutSik Jan 3, 2025
81d1d48
Another significant insertion.
MathieuDutSik Jan 3, 2025
30670d8
A bunch of corrections coming from code inspection.
MathieuDutSik Jan 4, 2025
a7e28b6
Resolve more bugs.
MathieuDutSik Jan 4, 2025
5bb64c5
Have the first code working correctly for SimpleEnum.
MathieuDutSik Jan 4, 2025
e8fbbe1
Several more corrections.
MathieuDutSik Jan 4, 2025
2cb4d52
Address one more bug.
MathieuDutSik Jan 4, 2025
f2c8144
Address a number of bugs related to the memory location.
MathieuDutSik Jan 4, 2025
15976b0
Resolve several more issues. More work is needed.
MathieuDutSik Jan 5, 2025
73f7982
Further problem.
MathieuDutSik Jan 5, 2025
f01033d
Cleanup of the code. Now it finally compiles.
MathieuDutSik Jan 5, 2025
a5d6ca0
Some simplification of the data_location stuff.
MathieuDutSik Jan 7, 2025
8acefd3
Add code for testing for circular dependencies.
MathieuDutSik Jan 7, 2025
f3cf483
Debug the circular dependency code.
MathieuDutSik Jan 7, 2025
23a7d1e
Insert the code for the solidity generation.
MathieuDutSik Jan 9, 2025
4b04ad2
Some basic corrections for compilation.
MathieuDutSik Jan 9, 2025
3fdf2b0
The compilation now passes.
MathieuDutSik Jan 9, 2025
950e223
Corrections for compilation.
MathieuDutSik Jan 9, 2025
925a607
Now the stuff compiles and yes we can get the bytecode.
MathieuDutSik Jan 10, 2025
a89b0df
Insert one more test code.
MathieuDutSik Jan 10, 2025
1ea26bd
Make the code compiles and without warning.
MathieuDutSik Jan 10, 2025
c40cd4c
Switch from uint64 to uint256 for the positions.
MathieuDutSik Jan 11, 2025
86da4b8
Make the code compile.
MathieuDutSik Jan 11, 2025
e453658
Improve the support, but the bytes does not compile accordingly.
MathieuDutSik Jan 11, 2025
95d228c
Address some issue and now the stuff compiles.
MathieuDutSik Jan 12, 2025
6414782
Now the test code does compile.
MathieuDutSik Jan 12, 2025
9315abf
Progress the runtime.
MathieuDutSik Jan 13, 2025
1de463b
Another correction.
MathieuDutSik Jan 13, 2025
98edfd2
Iron out a bunch of errors.
MathieuDutSik Jan 14, 2025
a955495
Further corrections.
MathieuDutSik Jan 14, 2025
13ee2c4
More corrections.
MathieuDutSik Jan 14, 2025
61cd363
Make the test pass in particular of the signed value.
MathieuDutSik Jan 14, 2025
4ca2207
Remove some useless code in the test code.
MathieuDutSik Jan 14, 2025
1dd650d
Resolve another bug.
MathieuDutSik Jan 14, 2025
1857c45
Another cleanup.
MathieuDutSik Jan 14, 2025
d707ae5
Make the simple enum work correctly.
MathieuDutSik Jan 14, 2025
bd982da
Correct the support for the boolean and introduce another test case.
MathieuDutSik Jan 14, 2025
ef3d594
Iron out another bug.
MathieuDutSik Jan 14, 2025
844415a
Add one more test to the code and make the code more readable.
MathieuDutSik Jan 14, 2025
1ad1973
Clippy corrections and elimination of code used during the development.
MathieuDutSik Jan 14, 2025
e0ea445
Now formatting corrections.
MathieuDutSik Jan 14, 2025
5995b66
Reformatting error forgotten.
MathieuDutSik Jan 15, 2025
d6def0c
Address some clippy issues.
MathieuDutSik Jan 15, 2025
e542e1d
Switch the keywords to a static variable.
MathieuDutSik Jan 18, 2025
5a9d846
Make the routines method of SolRegistry.
MathieuDutSik Jan 18, 2025
db9d2ce
Formatting corrections.
MathieuDutSik Jan 18, 2025
06ef836
Remove the expect statement + add ViaIR stuff.
MathieuDutSik Jan 18, 2025
6ef58ba
Add the solidity compiler.
MathieuDutSik Jan 18, 2025
d01b860
Removing correction induced by clippy.
MathieuDutSik Jan 19, 2025
59f3fd2
Revert "Removing correction induced by clippy."
MathieuDutSik Jan 19, 2025
5b8396a
Some corrections at having the solc working.
MathieuDutSik Jan 20, 2025
a2b5f4a
Correct the solidity entry in the CI.
MathieuDutSik Jan 28, 2025
0859878
Simplifications from the reviewing process.
MathieuDutSik Jan 30, 2025
25071dc
Remove the matches! entry.
MathieuDutSik Jan 31, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 25 additions & 19 deletions serde-generate/src/solidity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -834,26 +834,32 @@ struct SolRegistry {
impl SolRegistry {
fn insert(&mut self, sol_format: SolFormat) {
let key_name = sol_format.key_name();
if matches!(sol_format, SolFormat::Primitive(Primitive::I8)) {
self.names
.insert("uint8".to_string(), SolFormat::Primitive(Primitive::U8));
}
if matches!(sol_format, SolFormat::Primitive(Primitive::I16)) {
self.names
.insert("uint16".to_string(), SolFormat::Primitive(Primitive::U16));
}
if matches!(sol_format, SolFormat::Primitive(Primitive::I32)) {
self.names
.insert("uint32".to_string(), SolFormat::Primitive(Primitive::U32));
}
if matches!(sol_format, SolFormat::Primitive(Primitive::I64)) {
self.names
.insert("uint64".to_string(), SolFormat::Primitive(Primitive::U64));
}
if matches!(sol_format, SolFormat::Primitive(Primitive::I128)) {
self.names
.insert("uint128".to_string(), SolFormat::Primitive(Primitive::U128));
// If we insert the signed version, then we also need the unsigned one internally
match sol_format {
SolFormat::Primitive(Primitive::I8) => {
self.names
.insert("uint8".to_string(), SolFormat::Primitive(Primitive::U8));
}
SolFormat::Primitive(Primitive::I16) => {
self.names
.insert("uint16".to_string(), SolFormat::Primitive(Primitive::U16));
}
SolFormat::Primitive(Primitive::I32) => {
self.names
.insert("uint32".to_string(), SolFormat::Primitive(Primitive::U32));
}
SolFormat::Primitive(Primitive::I64) => {
self.names
.insert("uint64".to_string(), SolFormat::Primitive(Primitive::U64));
}
SolFormat::Primitive(Primitive::I128) => {
self.names
.insert("uint128".to_string(), SolFormat::Primitive(Primitive::U128));
}
_ => {}
}
// Typename entries are by definition already covered and do not need
// to be inserted. Others do.
if !matches!(sol_format, SolFormat::TypeName(_)) {
self.names.insert(key_name, sol_format);
}
Copy link
Contributor

@ma2bd ma2bd Jan 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's really no need for matches! here.

SolFormat::Primitive(SolFormat::TypeName(_)) => {
    // Typename entries do not need to be inserted.
}
_ => {
    self.names.insert(key_name, sol_format);
}

Expand Down
2 changes: 1 addition & 1 deletion serde-generate/tests/solidity_generation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,5 @@ fn test_solidity_compilation() {
generator.output(&mut test_file, &registry).unwrap();
}

let _bytecode = get_bytecode(path, "test.sol", "test").unwrap();
get_bytecode(path, "test.sol", "test").unwrap();
}
22 changes: 4 additions & 18 deletions serde-generate/tests/solidity_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,8 @@ fn test_contract(bytecode: Bytes, encoded_args: Bytes) {

let result: ExecutionResult = evm.transact_commit().unwrap();

let ExecutionResult::Success {
reason: _,
gas_used: _,
gas_refunded: _,
logs: _,
output,
} = result
else {
panic!("The TxKind::Create execution failed to be done");
let ExecutionResult::Success { output, .. } = result else {
panic!("The TxKind::Create execution failed");
};
let Output::Create(_, Some(contract_address)) = output else {
panic!("Failure to create the contract");
Expand All @@ -54,15 +47,8 @@ fn test_contract(bytecode: Bytes, encoded_args: Bytes) {

let result: ExecutionResult = evm.transact_commit().unwrap();

let ExecutionResult::Success {
reason: _,
gas_used: _,
gas_refunded: _,
logs: _,
output: _,
} = result
else {
panic!("The TxKind::Call execution failed to be done");
let ExecutionResult::Success { .. } = result else {
panic!("The TxKind::Call execution failed");
};
}

Expand Down