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

Fixed to return uint256[] correctly when passed as type #147

Merged
merged 1 commit into from
Sep 26, 2022
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion lib/eth/contract/function_input.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def initialize(data)

# Returns complete types with subtypes, e.g., `uint256`.
def type
@type.base_type + @type.sub_type
@type.base_type + @type.sub_type + @type.dimensions.map { |dimension| "[#{dimension > 0 ? dimension : ""}]" }.join("")
end
end
end
2 changes: 1 addition & 1 deletion lib/eth/contract/function_output.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def initialize(data)

# Returns complete types with subtypes, e.g., `uint256`.
def type
@type.base_type + @type.sub_type
@type.base_type + @type.sub_type + @type.dimensions.map { |dimension| "[#{dimension > 0 ? dimension : ""}]" }.join("")
end
end
end
9 changes: 9 additions & 0 deletions spec/eth/contract/function_input_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,13 @@
expect(function_input.type).to eq("uint256")
expect(function_input).to be_instance_of Contract::FunctionInput
end

context "with an array type" do
subject(:function_with_array) { Contract::FunctionInput.new({ "name" => "array", "type" => "uint256[]" }) }
it "creates FunctionInput objects" do
expect(function_with_array.name).to eq("array")
expect(function_with_array.type).to eq("uint256[]")
expect(function_with_array).to be_instance_of Contract::FunctionInput
end
end
end
9 changes: 9 additions & 0 deletions spec/eth/contract/function_output_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,13 @@
expect(function_output.type).to eq("uint256")
expect(function_output).to be_instance_of Contract::FunctionOutput
end

context "with an array type" do
subject(:function_with_array) { Contract::FunctionOutput.new({ "name" => "array", "type" => "uint256[]" }) }
it "creates FunctionInput objects" do
expect(function_with_array.name).to eq("array")
expect(function_with_array.type).to eq("uint256[]")
expect(function_with_array).to be_instance_of Contract::FunctionOutput
end
end
end