This repository has been archived by the owner on Oct 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 794
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIX: Generate structs for constructor arguments (#2631)
* BUG: Constructor parameters not generated * FIX: Use the name 'constructor' if there is empty
- Loading branch information
Showing
4 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
ethers-contract/tests/solidity-contracts/StructConstructor.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"abi": [{"inputs":[{"components":[{"internalType":"uint256","name":"x","type":"uint256"},{"internalType":"uint256","name":"y","type":"uint256"}],"internalType":"struct MyContract.ConstructorParams","name":"params","type":"tuple"}],"stateMutability":"nonpayable","type":"constructor"}], "bin": "608060405234801561001057600080fd5b506040516101df3803806101df833981810160405281019061003291906100b2565b8060008082015181600001556020820151816001015590505050610192565b60006040828403121561006357600080fd5b61006d60406100db565b9050600061007d8482850161009d565b60008301525060206100918482850161009d565b60208301525092915050565b6000815190506100ac8161017b565b92915050565b6000604082840312156100c457600080fd5b60006100d284828501610051565b91505092915050565b60006100e56100f6565b90506100f1828261010a565b919050565b6000604051905090565b6000819050919050565b6101138261016a565b810181811067ffffffffffffffff821117156101325761013161013b565b5b80604052505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b61018481610100565b811461018f57600080fd5b50565b603f806101a06000396000f3fe6080604052600080fdfea2646970667358221220bbd84df82374c1aa309661efb1096e8b1edc2b6fd57eaa1d43c53908b04321b864736f6c63430008020033"} |
22 changes: 22 additions & 0 deletions
22
ethers-contract/tests/solidity-contracts/StructConstructor.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity >=0.8; | ||
|
||
// To sync with StructContractor.json run: | ||
|
||
// CONTRACT=ethers-contract/tests/solidity-contracts/StructConstructor | ||
// BIN=$(solc --bin $CONTRACT.sol | sed '4q;d' | tr -d '\n') | ||
// ABI=$(solc --abi $CONTRACT.sol | tail -n 1) | ||
// echo "{\"abi\": $ABI, \"bin\": \"$BIN\"}" > $CONTRACT.json | ||
|
||
contract MyContract { | ||
struct ConstructorParams { | ||
uint256 x; | ||
uint256 y; | ||
} | ||
|
||
ConstructorParams _params; | ||
|
||
constructor(ConstructorParams memory params) { | ||
_params = params; | ||
} | ||
} |