Skip to content

Commit a315b0d

Browse files
authored
feat: add constructorCall to sol! (#493)
* feat: add constructorCall to `sol!` * fix: nits
1 parent db54aca commit a315b0d

File tree

19 files changed

+162
-15
lines changed

19 files changed

+162
-15
lines changed

crates/json-abi/src/to_sol.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::{
2-
item::{Error, Event, Fallback, Function, Receive},
2+
item::{Constructor, Error, Event, Fallback, Function, Receive},
33
EventParam, InternalType, JsonAbi, Param, StateMutability,
44
};
55
use alloc::{collections::BTreeSet, string::String, vec::Vec};
@@ -69,6 +69,7 @@ impl ToSol for JsonAbi {
6969
fmt!(its.0);
7070
fmt!(self.errors());
7171
fmt!(self.events());
72+
fmt!(self.constructor());
7273
fmt!(self.fallback);
7374
fmt!(self.receive);
7475
fmt!(self.functions());
@@ -233,6 +234,21 @@ impl ToSol for It<'_> {
233234
}
234235
}
235236

237+
impl ToSol for Constructor {
238+
fn to_sol(&self, out: &mut SolPrinter<'_>) {
239+
AbiFunction::<'_, Param> {
240+
kw: AbiFunctionKw::Constructor,
241+
name: None,
242+
inputs: &self.inputs,
243+
visibility: None,
244+
state_mutability: Some(self.state_mutability),
245+
anonymous: false,
246+
outputs: &[],
247+
}
248+
.to_sol(out);
249+
}
250+
}
251+
236252
impl ToSol for Event {
237253
fn to_sol(&self, out: &mut SolPrinter<'_>) {
238254
AbiFunction::<'_, EventParam> {
@@ -319,6 +335,7 @@ struct AbiFunction<'a, IN> {
319335
}
320336

321337
enum AbiFunctionKw {
338+
Constructor,
322339
Function,
323340
Fallback,
324341
Receive,
@@ -330,6 +347,7 @@ impl AbiFunctionKw {
330347
#[inline]
331348
const fn as_str(&self) -> &'static str {
332349
match self {
350+
Self::Constructor => "constructor",
333351
Self::Function => "function",
334352
Self::Fallback => "fallback",
335353
Self::Receive => "receive",

crates/json-abi/tests/abi/AggregationRouterV5.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ interface AggregationRouterV5 {
8484
event OrderFilledRFQ(bytes32 orderHash, uint256 makingAmount);
8585
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
8686

87+
constructor(address weth);
88+
8789
receive() external payable;
8890

8991
function advanceNonce(uint8 amount) external;

crates/json-abi/tests/abi/BlurExchange.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ interface BlurExchange {
5252
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
5353
event Upgraded(address indexed implementation);
5454

55+
constructor();
56+
5557
function FEE_TYPEHASH() external view returns (bytes32);
5658
function INVERSE_BASIS_POINT() external view returns (uint256);
5759
function NAME() external view returns (string memory);

crates/json-abi/tests/abi/DoubleExponentInterestSetter.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
interface DoubleExponentInterestSetter {
2+
constructor((uint128, uint128) params);
3+
24
function getCoefficients() external view returns (uint256[] memory);
35
function getInterestRate(address, uint256 borrowWei, uint256 supplyWei) external view returns ((uint256,) memory);
46
function getMaxAPR() external view returns (uint256);

crates/json-abi/tests/abi/GaugeController.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ interface GaugeController {
77
event NewTypeWeight(int128 type_id, uint256 time, uint256 weight, uint256 total_weight);
88
event VoteForGauge(uint256 time, address user, address gauge_addr, uint256 weight);
99

10+
constructor(address _token, address _voting_escrow);
11+
1012
function add_gauge(address addr, int128 gauge_type, uint256 weight) external;
1113
function add_type(string memory _name, uint256 weight) external;
1214
function admin() external view returns (address);

crates/json-abi/tests/abi/GnosisSafe.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ interface GnosisSafe {
1414
event RemovedOwner(address owner);
1515
event SignMsg(bytes32 indexed msgHash);
1616

17+
constructor();
18+
1719
fallback() external payable;
1820

1921
function NAME() external view returns (string memory);

crates/json-abi/tests/abi/Junkyard.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ interface Junkyard {
1515
event PricesChange(uint256, uint256);
1616
event Unpaused(address account);
1717

18+
constructor(address[] jkdPayees, uint256[] jkdShares, address _gateway, address _gasReceiver);
19+
1820
receive() external payable;
1921

2022
function GAS_RECEIVER() external view returns (address);

crates/json-abi/tests/abi/LiquidityGaugeV4.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ interface LiquidityGaugeV4 {
88
event UpdateLiquidityLimit(address user, uint256 original_balance, uint256 original_supply, uint256 working_balance, uint256 working_supply);
99
event Withdraw(address indexed provider, uint256 value);
1010

11+
constructor();
12+
1113
function SDT() external view returns (address);
1214
function accept_transfer_ownership() external;
1315
function add_reward(address _reward_token, address _distributor) external;

crates/json-abi/tests/abi/Seaport.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ interface Seaport {
165165
event OrderValidated(bytes32 orderHash, OrderParameters orderParameters);
166166
event OrdersMatched(bytes32[] orderHashes);
167167

168+
constructor(address conduitController);
169+
168170
receive() external payable;
169171

170172
function cancel(OrderComponents[] memory orders) external returns (bool cancelled);

crates/json-abi/tests/abi/UniswapV2Factory.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
interface UniswapV2Factory {
22
event PairCreated(address indexed token0, address indexed token1, address pair, uint256);
33

4+
constructor(address _feeToSetter);
5+
46
function allPairs(uint256) external view returns (address);
57
function allPairsLength() external view returns (uint256);
68
function createPair(address tokenA, address tokenB) external returns (address pair);

0 commit comments

Comments
 (0)