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

Support camel case (convert before sending the tx) #172

Merged
merged 1 commit into from
Dec 21, 2022
Merged
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions lib/eth/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -452,11 +452,21 @@ def next_id
@id += 1
end

# expects Hash object
def camelize!(params)
params.transform_keys! do |k|
k = k.to_s.split(/_/).map(&:capitalize).join
k[0] = k[0].downcase
k.to_sym
end
end

# Recursively marshals all request parameters.
def marshal(params)
if params.is_a? Array
return params.map! { |param| marshal(param) }
elsif params.is_a? Hash
params = camelize!(params)
return params.transform_values! { |param| marshal(param) }
elsif params.is_a? Numeric
return Util.prefix_hex "#{params.to_i.to_s(16)}"
Expand Down