Skip to content
This repository was archived by the owner on Dec 9, 2022. It is now read-only.

Commit 7ad2f61

Browse files
authored
make docs natspec compatible (#15)
1 parent 142a1e9 commit 7ad2f61

File tree

4 files changed

+49
-59
lines changed

4 files changed

+49
-59
lines changed

contracts/v0.8/MarketAPI.sol

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ contract MarketAPI {
1515
mock_generate_deals();
1616
}
1717

18-
/// Deposits the received value into the balance held in escrow.
18+
/// @notice Deposits the received value into the balance held in escrow.
1919
/// @dev Because this is a mock method, no real balance is being deducted from the caller, nor incremented in the Storage Market actor (f05).
2020
function add_balance(
2121
MarketTypes.AddBalanceParams memory params
2222
) public payable {
2323
balances[params.provider_or_client] += msg.value;
2424
}
2525

26-
/// Attempt to withdraw the specified amount from the balance held in escrow.
27-
/// If less than the specified amount is available, yields the entire available balance.
26+
/// @notice Attempt to withdraw the specified amount from the balance held in escrow.
27+
/// @notice If less than the specified amount is available, yields the entire available balance.
2828
/// @dev This method should be called by an approved address, but the mock does not check that the caller is an approved party.
2929
/// @dev Because this is a mock method, no real balance is deposited in the designated address, nor decremented from the Storage Market actor (f05).
3030
function withdraw_balance(
@@ -41,7 +41,7 @@ contract MarketAPI {
4141
return MarketTypes.WithdrawBalanceReturn(tmp);
4242
}
4343

44-
/// Returns the escrow balance and locked amount for an address.
44+
/// @return the escrow balance and locked amount for an address.
4545
function get_balance(
4646
string memory addr
4747
) public view returns (MarketTypes.GetBalanceReturn memory) {
@@ -50,11 +50,9 @@ contract MarketAPI {
5050
return MarketTypes.GetBalanceReturn(actualBalance, 0);
5151
}
5252

53-
/// Returns the data commitment and size of a deal proposal.
54-
/// This will be available after the deal is published (whether or not is is activated)
55-
/// and up until some undefined period after it is terminated.
56-
/// FIXME set data values correctly, currently returning fixed data, feel free to adjust
57-
/// in your local mock.
53+
/// @return the data commitment and size of a deal proposal.
54+
/// @notice This will be available after the deal is published (whether or not is is activated) and up until some undefined period after it is terminated.
55+
/// @dev set data values correctly, currently returning fixed data, feel free to adjust in your local mock.
5856
function get_deal_data_commitment(
5957
MarketTypes.GetDealDataCommitmentParams memory params
6058
) public view returns (MarketTypes.GetDealDataCommitmentReturn memory) {
@@ -67,7 +65,7 @@ contract MarketAPI {
6765
);
6866
}
6967

70-
/// Returns the client of a deal proposal.
68+
/// @return the client of a deal proposal.
7169
function get_deal_client(
7270
MarketTypes.GetDealClientParams memory params
7371
) public view returns (MarketTypes.GetDealClientReturn memory) {
@@ -76,7 +74,7 @@ contract MarketAPI {
7674
return MarketTypes.GetDealClientReturn(deals[params.id].client);
7775
}
7876

79-
/// Returns the provider of a deal proposal.
77+
/// @return the provider of a deal proposal.
8078
function get_deal_provider(
8179
MarketTypes.GetDealProviderParams memory params
8280
) public view returns (MarketTypes.GetDealProviderReturn memory) {
@@ -85,7 +83,7 @@ contract MarketAPI {
8583
return MarketTypes.GetDealProviderReturn(deals[params.id].provider);
8684
}
8785

88-
/// Returns the label of a deal proposal.
86+
/// @return the label of a deal proposal.
8987
function get_deal_label(
9088
MarketTypes.GetDealLabelParams memory params
9189
) public view returns (MarketTypes.GetDealLabelReturn memory) {
@@ -94,7 +92,7 @@ contract MarketAPI {
9492
return MarketTypes.GetDealLabelReturn(deals[params.id].label);
9593
}
9694

97-
/// Returns the start epoch and duration (in epochs) of a deal proposal.
95+
/// @return the start epoch and duration (in epochs) of a deal proposal.
9896
function get_deal_term(
9997
MarketTypes.GetDealTermParams memory params
10098
) public view returns (MarketTypes.GetDealTermReturn memory) {
@@ -107,9 +105,8 @@ contract MarketAPI {
107105
);
108106
}
109107

110-
/// Returns the per-epoch price of a deal proposal.
111-
/// TODO renamed to get_deal_total_price in builtin-actors.
112-
function get_deal_epoch_price(
108+
/// @return the per-epoch price of a deal proposal.
109+
function get_deal_total_price(
113110
MarketTypes.GetDealEpochPriceParams memory params
114111
) public view returns (MarketTypes.GetDealEpochPriceReturn memory) {
115112
require(deals[params.id].id > 0);
@@ -120,7 +117,7 @@ contract MarketAPI {
120117
);
121118
}
122119

123-
/// Returns the client collateral requirement for a deal proposal.
120+
/// @return the client collateral requirement for a deal proposal.
124121
function get_deal_client_collateral(
125122
MarketTypes.GetDealClientCollateralParams memory params
126123
) public view returns (MarketTypes.GetDealClientCollateralReturn memory) {
@@ -132,7 +129,7 @@ contract MarketAPI {
132129
);
133130
}
134131

135-
/// Returns the provider collateral requirement for a deal proposal.
132+
/// @return the provider collateral requirement for a deal proposal.
136133
function get_deal_provider_collateral(
137134
MarketTypes.GetDealProviderCollateralParams memory params
138135
) public view returns (MarketTypes.GetDealProviderCollateralReturn memory) {
@@ -144,9 +141,8 @@ contract MarketAPI {
144141
);
145142
}
146143

147-
/// Returns the verified flag for a deal proposal.
148-
/// Note that the source of truth for verified allocations and claims is
149-
/// the verified registry actor.
144+
/// @return the verified flag for a deal proposal.
145+
/// @notice Note that the source of truth for verified allocations and claims is the verified registry actor.
150146
function get_deal_verified(
151147
MarketTypes.GetDealVerifiedParams memory params
152148
) public view returns (MarketTypes.GetDealVerifiedReturn memory) {
@@ -155,11 +151,9 @@ contract MarketAPI {
155151
return MarketTypes.GetDealVerifiedReturn(deals[params.id].verified);
156152
}
157153

158-
/// Fetches activation state for a deal.
159-
/// This will be available from when the proposal is published until an undefined period after
160-
/// the deal finishes (either normally or by termination).
161-
/// Returns USR_NOT_FOUND if the deal doesn't exist (yet), or EX_DEAL_EXPIRED if the deal
162-
/// has been removed from state.
154+
/// @notice Fetches activation state for a deal.
155+
/// @notice This will be available from when the proposal is published until an undefined period after the deal finishes (either normally or by termination).
156+
/// @return USR_NOT_FOUND if the deal doesn't exist (yet), or EX_DEAL_EXPIRED if the deal has been removed from state.
163157
function get_deal_activation(
164158
MarketTypes.GetDealActivationParams memory params
165159
) public view returns (MarketTypes.GetDealActivationReturn memory) {
@@ -172,9 +166,8 @@ contract MarketAPI {
172166
);
173167
}
174168

175-
/// Publish a new set of storage deals (not yet included in a sector).
176-
/// TODO renamed to publish_storage_deals, taking a vector.
177-
function publish_deal(bytes memory raw_auth_params, address callee) public {
169+
/// @notice Publish a new set of storage deals (not yet included in a sector).
170+
function publish_storage_deals(bytes memory raw_auth_params, address callee) public {
178171
// calls standard filecoin receiver on message authentication api method number
179172
(bool success, ) = callee.call(
180173
abi.encodeWithSignature(
@@ -187,7 +180,7 @@ contract MarketAPI {
187180
require(success, "client contract failed to authorize deal publish");
188181
}
189182

190-
/// Adds mock deal data to the internal state of this mock.
183+
/// @notice Adds mock deal data to the internal state of this mock.
191184
/// @dev Feel free to adjust the data here to make it align with deals in your network.
192185
function mock_generate_deals() internal {
193186
MarketTypes.MockDeal memory deal_67;

contracts/v0.8/MinerAPI.sol

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ contract MinerAPI {
1313
CommonTypes.ActiveBeneficiary activeBeneficiary;
1414
mapping(CommonTypes.SectorSize => uint64) sectorSizesBytes;
1515

16+
/// @notice (Mock method) Sets the owner of a Miner on contract deployment, which will be returned via get_owner().
1617
constructor(string memory _owner) {
1718
owner = _owner;
1819

@@ -23,15 +24,15 @@ contract MinerAPI {
2324
sectorSizesBytes[CommonTypes.SectorSize._64GiB] = 2 * (32 << 30);
2425
}
2526

26-
/// (Mock method) Sets the owner of a Miner, which will be returned via get_owner().
27+
/// @notice (Mock method) Sets the owner of a Miner, which will be returned via get_owner().
2728
function mock_set_owner(string memory addr) public {
2829
require(bytes(owner).length == 0);
2930
owner = addr;
3031
}
3132

32-
/// Returns the owner address of a Miner.
33-
/// - Income and returned collateral are paid to this address
34-
/// - This address is also allowed to change the worker address for the miner
33+
/// @notice Income and returned collateral are paid to this address
34+
/// @notice This address is also allowed to change the worker address for the miner
35+
/// @return the owner address of a Miner
3536
function get_owner()
3637
public
3738
view
@@ -42,51 +43,49 @@ contract MinerAPI {
4243
return MinerTypes.GetOwnerReturn(owner);
4344
}
4445

45-
/// Proposes or confirms a change of owner address.
46-
/// If invoked by the current owner, proposes a new owner address for confirmation. If the proposed address is the
47-
/// current owner address, revokes any existing proposal.
48-
/// If invoked by the previously proposed address, with the same proposal, changes the current owner address to be
49-
/// that proposed address.
46+
/// @param addr New owner address
47+
/// @notice Proposes or confirms a change of owner address.
48+
/// @notice If invoked by the current owner, proposes a new owner address for confirmation. If the proposed address is the current owner address, revokes any existing proposal that proposed address.
5049
function change_owner_address(string memory addr) public {
5150
owner = addr;
5251
}
5352

54-
/// Returns whether the provided address is "controlling".
55-
/// The "controlling" addresses are the Owner, the Worker, and all Control Addresses.
53+
/// @param params The "controlling" addresses are the Owner, the Worker, and all Control Addresses.
54+
/// @return Whether the provided address is "controlling".
5655
function is_controlling_address(
5756
MinerTypes.IsControllingAddressParam memory params
5857
) public pure returns (MinerTypes.IsControllingAddressReturn memory) {
5958
return MinerTypes.IsControllingAddressReturn(false);
6059
}
6160

62-
/// Returns the miner's sector size.
61+
/// @return the miner's sector size.
6362
function get_sector_size()
6463
public
6564
view
66-
returns (MinerTypes.GetSectorSizeReturn memory params)
65+
returns (MinerTypes.GetSectorSizeReturn memory)
6766
{
6867
return
6968
MinerTypes.GetSectorSizeReturn(
7069
sectorSizesBytes[CommonTypes.SectorSize._8MiB]
7170
);
7271
}
7372

74-
/// Returns the available balance of this miner.
75-
/// This is calculated as actor balance - (vesting funds + pre-commit deposit + initial pledge requirement + fee debt)
76-
/// Can go negative if the miner is in IP debt.
73+
/// @notice This is calculated as actor balance - (vesting funds + pre-commit deposit + initial pledge requirement + fee debt)
74+
/// @notice Can go negative if the miner is in IP debt.
75+
/// @return the available balance of this miner.
7776
function get_available_balance()
7877
public
7978
pure
80-
returns (MinerTypes.GetAvailableBalanceReturn memory params)
79+
returns (MinerTypes.GetAvailableBalanceReturn memory)
8180
{
8281
return MinerTypes.GetAvailableBalanceReturn(10000000000000000000000);
8382
}
8483

85-
/// Returns the funds vesting in this miner as a list of (vesting_epoch, vesting_amount) tuples.
84+
/// @return the funds vesting in this miner as a list of (vesting_epoch, vesting_amount) tuples.
8685
function get_vesting_funds()
8786
public
8887
pure
89-
returns (MinerTypes.GetVestingFundsReturn memory params)
88+
returns (MinerTypes.GetVestingFundsReturn memory)
9089
{
9190
CommonTypes.VestingFunds[]
9291
memory vesting_funds = new CommonTypes.VestingFunds[](1);
@@ -98,10 +97,9 @@ contract MinerAPI {
9897
return MinerTypes.GetVestingFundsReturn(vesting_funds);
9998
}
10099

101-
/// Proposes or confirms a change of beneficiary address.
102-
/// A proposal must be submitted by the owner, and takes effect after approval of both the proposed beneficiary and current beneficiary,
103-
/// if applicable, any current beneficiary that has time and quota remaining.
104-
/// See FIP-0029, https://github.com/filecoin-project/FIPs/blob/master/FIPS/fip-0029.md
100+
/// @notice Proposes or confirms a change of beneficiary address.
101+
/// @notice A proposal must be submitted by the owner, and takes effect after approval of both the proposed beneficiary and current beneficiary, if applicable, any current beneficiary that has time and quota remaining.
102+
/// @notice See FIP-0029, https://github.com/filecoin-project/FIPs/blob/master/FIPS/fip-0029.md
105103
function change_beneficiary(
106104
MinerTypes.ChangeBeneficiaryParams memory params
107105
) public {
@@ -120,9 +118,8 @@ contract MinerAPI {
120118
}
121119
}
122120

123-
/// Retrieves the currently active and proposed beneficiary information.
124-
/// This method is for use by other actors (such as those acting as beneficiaries),
125-
/// and to abstract the state representation for clients.
121+
/// @notice This method is for use by other actors (such as those acting as beneficiaries), and to abstract the state representation for clients.
122+
/// @notice Retrieves the currently active and proposed beneficiary information.
126123
function get_beneficiary()
127124
public
128125
view

contracts/v0.8/testContracts/market.test.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ contract FilecoinMarketMockTest {
124124
return response;
125125
}
126126

127-
function get_deal_epoch_price_test()
127+
function get_deal_total_price_test()
128128
public
129129
view
130130
returns (MarketTypes.GetDealEpochPriceReturn memory)
@@ -135,7 +135,7 @@ contract FilecoinMarketMockTest {
135135
.GetDealEpochPriceParams(67);
136136

137137
MarketTypes.GetDealEpochPriceReturn memory response = marketApiInstance
138-
.get_deal_epoch_price(params);
138+
.get_deal_total_price(params);
139139
return response;
140140
}
141141

docs/specifications.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ sidebar_position: 2
286286
| Return | int64 start; | | | Return data in the mock deals tab; if deal_id does not exisit in that tab, return error |
287287
| | int64 end; | | | Return data in the mock deals tab; if deal_id does not exisit in that tab, return error |
288288
| | | | | |
289-
| get_deal_epoch_price | | | | |
289+
| get_deal_total_price | | | | |
290290
| Params | uint64 deal_id; | | | Return data in the mock deals tab; if deal_id does not exisit in that tab, return error |
291291
| Return | uint256 price_per_epoch; | | | Return data in the mock deals tab; if deal_id does not exisit in that tab, return error |
292292
| | | | | |

0 commit comments

Comments
 (0)