-
-
Notifications
You must be signed in to change notification settings - Fork 41
fix: Zig build and tests #1720
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: Zig build and tests #1720
Changes from all commits
4c350c0
beec7bf
23ee765
404c3df
63c8077
e809f99
3ab25df
3250cc1
2e3866f
aae66ea
58e660f
b64ade0
b526473
353b690
0e6b40c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,3 +91,5 @@ zig-cache/ | |
TODO.md | ||
|
||
**/.claude/settings.local.json | ||
|
||
g/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ members = [ | |
|
||
[profile.release] | ||
lto = true | ||
panic = "abort" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,243 +1,11 @@ | ||
// Placeholder ABI module | ||
// The actual ABI implementation is in g/compilers/src/Abi/ | ||
const std = @import("std"); | ||
|
||
/// State mutability of functions and constructors | ||
pub const StateMutability = enum { | ||
Pure, | ||
View, | ||
NonPayable, | ||
Payable, | ||
pub const AbiError = error{ | ||
InvalidInput, | ||
}; | ||
|
||
/// Represents Solidity internal types | ||
pub const InternalType = union(enum) { | ||
AddressPayable: []const u8, | ||
Contract: []const u8, | ||
Enum: struct { | ||
contract: ?[]const u8, | ||
ty: []const u8, | ||
}, | ||
Struct: struct { | ||
contract: ?[]const u8, | ||
ty: []const u8, | ||
}, | ||
Other: struct { | ||
contract: ?[]const u8, | ||
ty: []const u8, | ||
}, | ||
}; | ||
|
||
/// ABI parameter for inputs and outputs | ||
pub const Param = struct { | ||
ty: []const u8, | ||
name: []const u8, | ||
components: []Param, | ||
internal_type: ?InternalType, | ||
}; | ||
|
||
/// ABI event parameter (with indexing) | ||
pub const EventParam = struct { | ||
ty: []const u8, | ||
name: []const u8, | ||
indexed: bool, | ||
components: []Param, | ||
internal_type: ?InternalType, | ||
}; | ||
|
||
/// Constructor ABI item | ||
pub const Constructor = struct { | ||
inputs: []Param, | ||
state_mutability: StateMutability, | ||
}; | ||
|
||
/// Function ABI item | ||
pub const Function = struct { | ||
name: []const u8, | ||
inputs: []Param, | ||
outputs: []Param, | ||
state_mutability: StateMutability, | ||
}; | ||
|
||
/// Event ABI item | ||
pub const Event = struct { | ||
name: []const u8, | ||
inputs: []EventParam, | ||
anonymous: bool, | ||
}; | ||
|
||
/// Error ABI item | ||
pub const Error = struct { | ||
name: []const u8, | ||
inputs: []Param, | ||
}; | ||
|
||
/// Fallback ABI item | ||
pub const Fallback = struct { | ||
state_mutability: StateMutability, | ||
}; | ||
|
||
/// Receive ABI item | ||
pub const Receive = struct { | ||
state_mutability: StateMutability, | ||
}; | ||
|
||
/// Union of all ABI items | ||
pub const AbiItem = union(enum) { | ||
Constructor: Constructor, | ||
Fallback: Fallback, | ||
Receive: Receive, | ||
Function: Function, | ||
Event: Event, | ||
Error: Error, | ||
}; | ||
|
||
/// JSON ABI representation | ||
pub const JsonAbi = struct { | ||
constructor: ?Constructor = null, | ||
fallback: ?Fallback = null, | ||
receive: ?Receive = null, | ||
functions: std.StringHashMap([]Function), | ||
events: std.StringHashMap([]Event), | ||
errors: std.StringHashMap([]Error), | ||
|
||
/// Initialize an empty ABI | ||
pub fn init(_: *std.mem.Allocator) !JsonAbi { | ||
unreachable; | ||
} | ||
|
||
/// Insert a single item into the ABI | ||
pub fn insertItem(_: *JsonAbi, _: AbiItem) void { | ||
unreachable; | ||
} | ||
|
||
/// Parse human-readable ABI at compile time | ||
pub fn parseHumanReadable(comptime _: [][]const u8) JsonAbi { | ||
unreachable; | ||
} | ||
|
||
/// Parse human-readable ABI at runtime | ||
pub fn parseHumanReadableRuntime( | ||
_: *std.mem.Allocator, | ||
_: [][]const u8, | ||
) !JsonAbi { | ||
unreachable; | ||
} | ||
|
||
/// Parse JSON ABI blob | ||
pub fn parseJSON( | ||
_: *std.mem.Allocator, | ||
_: []const u8, | ||
) !JsonAbi { | ||
unreachable; | ||
} | ||
|
||
/// Load from reader (e.g., file) | ||
pub fn loadFromReader( | ||
_: *std.mem.Allocator, | ||
_: anytype, | ||
) !JsonAbi { | ||
unreachable; | ||
} | ||
|
||
/// Number of items in the ABI | ||
pub fn len(_: *const JsonAbi) usize { | ||
unreachable; | ||
} | ||
|
||
/// True if no items | ||
pub fn isEmpty(_: *const JsonAbi) bool { | ||
unreachable; | ||
} | ||
|
||
/// Remove duplicate functions, events, errors | ||
pub fn dedup(_: *JsonAbi) void { | ||
unreachable; | ||
} | ||
|
||
/// Iterate over items (immutable) | ||
pub fn items(_: *const JsonAbi) Items { | ||
unreachable; | ||
} | ||
|
||
/// Consume and iterate over items | ||
pub fn intoItems(_: JsonAbi) IntoItems { | ||
unreachable; | ||
} | ||
|
||
/// Render as Solidity interface source | ||
pub fn toSol( | ||
_: *const JsonAbi, | ||
_: *std.mem.Allocator, | ||
_: []const u8, | ||
_: ToSolConfig, | ||
) ![]u8 { | ||
unreachable; | ||
} | ||
|
||
/// Render into provided buffer | ||
pub fn toSolRaw( | ||
_: *const JsonAbi, | ||
_: []u8, | ||
_: []const u8, | ||
_: ToSolConfig, | ||
) void { | ||
unreachable; | ||
} | ||
}; | ||
|
||
/// Iterator type over JsonAbi items | ||
pub const Items = struct { | ||
// fields omitted | ||
|
||
pub fn next(self: *Items) ?AbiItem { | ||
unreachable; | ||
} | ||
}; | ||
|
||
/// Consuming iterator type over JsonAbi items | ||
pub const IntoItems = struct { | ||
// fields omitted | ||
|
||
pub fn next(self: *IntoItems) ?AbiItem { | ||
unreachable; | ||
} | ||
}; | ||
|
||
/// Contract artifact (ABI + bytecodes) | ||
pub const ContractObject = struct { | ||
abi: ?JsonAbi, | ||
bytecode: ?[]u8, | ||
deployed_bytecode: ?[]u8, | ||
|
||
/// Initialize empty | ||
pub fn init(allocator: *std.mem.Allocator) !ContractObject { | ||
unreachable; | ||
} | ||
|
||
/// Parse from JSON with optional unlinked bytecode | ||
pub fn parseJSON( | ||
s: []const u8, | ||
ignore_unlinked_bytecode: bool, | ||
) !ContractObject { | ||
unreachable; | ||
} | ||
}; | ||
|
||
/// Configuration for solidity rendering | ||
pub const ToSolConfig = struct { | ||
print_constructors: bool = false, | ||
enums_as_udvt: bool = true, | ||
for_sol_macro: bool = false, | ||
one_contract: bool = false, | ||
}; | ||
|
||
/// Compute Keccak-256 hash | ||
pub fn keccak256(data: []const u8) [32]u8 { | ||
unreachable; AAC9 | ||
} | ||
|
||
/// Compute 4-byte selector | ||
pub fn computeSelector(preimage: []const u8) [4]u8 { | ||
unreachable; | ||
} | ||
|
||
|
||
test { | ||
std.testing.refAllDeclsRecursive(@This()); | ||
} | ||
Comment on lines
+1
to
+11
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainVerify that no other modules depend on the removed ABI implementation. This placeholder module removes all ABI functionality that was previously available. This could break other parts of the codebase that import this module. Run the following script to check for dependencies on this module: 🏁 Script executed: #!/bin/bash
# Description: Check for imports of the ABI module that might be broken by this change
# Search for imports of the ABI module
echo "=== Searching for imports of Abi modules ==="
rg -t zig "@import.*Abi" --glob '!src/Abi/*' --glob '!g/*'
# Search for usage of ABI types that were previously exported
echo -e "\n=== Searching for usage of ABI types ==="
rg -t zig "(JsonAbi|AbiItem|Function|Event|Constructor|StateMutability)" --glob '!src/Abi/*' --glob '!g/*'
# Check if any files reference AbiError specifically
echo -e "\n=== Searching for AbiError usage ==="
rg -t zig "AbiError" --glob '!src/Abi/*' --glob '!g/*' Length of output: 1344 Update broken import in eip712.zig The only external dependency on const struct_type = @import("../Abi/struct_type.zig"); Since all ABI logic now lives under No other imports of the old 🤖 Prompt for AI Agents
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Verify Rust library path and consider build automation.
The Rust integration setup looks correct, but consider the following:
"dist/target/rel 9E7A ease/libfoundry_wrapper.a"
assumes a specific build locationConsider verifying that the Rust build step actually produces the library at the expected path:
🏁 Script executed:
Length of output: 343
🏁 Script executed:
Length of output: 3749
Ensure Rust library output and path alignment
The build is configured to emit the Rust artifact into
dist/target/release/libfoundry_wrapper.a
via therust_build
step, but we should guard against mismatches between the actual crate output and where it’s being linked:src/Compilers/Cargo.toml
that you’ve declared.a
archive rather than an.rlib
."dist/target/release/libfoundry_wrapper.a"
inbuild.zig
, pull in the samerust_lib_path
you define inrust_build.zig
(e.g. export it or return it fromaddRustIntegration
) to avoid drift.dist/target
directory and crate name into shared constants so both your Rust step and Zig linker invocation stay in sync.🤖 Prompt for AI Agents