Skip to content

Commit 491b574

Browse files
authored
fix solidity examples in precompile readmes (#458)
1 parent e2930f6 commit 491b574

File tree

3 files changed

+104
-23
lines changed

3 files changed

+104
-23
lines changed

precompiles/bech32/README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ This enables smart contracts to interact with Cosmos SDK modules that require be
1616
#### hexToBech32
1717

1818
```solidity
19-
function hexToBech32(address addr, string memory prefix) external returns (string memory bech32Address)
19+
function hexToBech32(
20+
address addr,
21+
string memory prefix
22+
) external returns (string memory bech32Address);
2023
```
2124

2225
Converts an Ethereum hex address to bech32 format with the specified human-readable prefix (HRP).
@@ -39,7 +42,9 @@ Converts an Ethereum hex address to bech32 format with the specified human-reada
3942
#### bech32ToHex
4043

4144
```solidity
42-
function bech32ToHex(string memory bech32Address) external returns (address addr)
45+
function bech32ToHex(
46+
string memory bech32Address
47+
) external returns (address addr);
4348
```
4449

4550
Converts a bech32-formatted address to Ethereum hex format.

precompiles/distribution/README.md

Lines changed: 58 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ withdrawing, and funding.
1818
#### setWithdrawAddress
1919

2020
```solidity
21-
function setWithdrawAddress(address delegator, string memory withdrawerAddress) external returns (bool)
21+
function setWithdrawAddress(
22+
address delegator,
23+
string memory withdrawerAddress
24+
) external returns (bool);
2225
```
2326

2427
Sets the address authorized to withdraw rewards for a delegator.
@@ -35,7 +38,10 @@ Sets the address authorized to withdraw rewards for a delegator.
3538
#### withdrawDelegatorRewards
3639

3740
```solidity
38-
function withdrawDelegatorRewards(address delegator, string memory validator) external returns (Coin[] memory)
41+
function withdrawDelegatorRewards(
42+
address delegator,
43+
string memory validator
44+
) external returns (Coin[] memory);
3945
```
4046

4147
Withdraws pending rewards from a specific validator.
@@ -56,7 +62,9 @@ Withdraws pending rewards from a specific validator.
5662
#### withdrawValidatorCommission
5763

5864
```solidity
59-
function withdrawValidatorCommission(string memory validator) external returns (Coin[] memory)
65+
function withdrawValidatorCommission(
66+
string memory validator
67+
) external returns (Coin[] memory);
6068
```
6169

6270
Withdraws accumulated commission for a validator.
@@ -76,7 +84,10 @@ Withdraws accumulated commission for a validator.
7684
#### claimRewards
7785

7886
```solidity
79-
function claimRewards(address delegator, uint32 maxRetrieve) external returns (bool)
87+
function claimRewards(
88+
address delegator,
89+
uint32 maxRetrieve
90+
) external returns (bool);
8091
```
8192

8293
Claims rewards from all validators at once (custom batch operation).
@@ -93,7 +104,10 @@ Claims rewards from all validators at once (custom batch operation).
93104
#### fundCommunityPool
94105

95106
```solidity
96-
function fundCommunityPool(address depositor, Coin[] memory coins) external returns (bool)
107+
function fundCommunityPool(
108+
address depositor,
109+
Coin[] memory coins
110+
) external returns (bool);
97111
```
98112

99113
Deposits tokens into the community pool.
@@ -110,7 +124,10 @@ Deposits tokens into the community pool.
110124
#### depositValidatorRewardsPool
111125

112126
```solidity
113-
function depositValidatorRewardsPool(string memory validator, Coin[] memory coins) external returns (bool)
127+
function depositValidatorRewardsPool(
128+
string memory validator,
129+
Coin[] memory coins
130+
) external returns (bool);
114131
```
115132

116133
Deposits tokens into a validator's rewards pool.
@@ -127,7 +144,12 @@ Deposits tokens into a validator's rewards pool.
127144
#### delegationTotalRewards
128145

129146
```solidity
130-
function delegationTotalRewards(address delegator) external view returns (DelegatorTotal[] memory, DecCoin[] memory)
147+
function delegationTotalRewards(
148+
address delegator
149+
) external view returns (
150+
DelegatorTotal[] memory,
151+
DecCoin[] memory
152+
);
131153
```
132154

133155
Returns total rewards across all validators for a delegator.
@@ -146,7 +168,10 @@ Returns total rewards across all validators for a delegator.
146168
#### delegationRewards
147169

148170
```solidity
149-
function delegationRewards(address delegator, string memory validator) external view returns (DecCoin[] memory)
171+
function delegationRewards(
172+
address delegator,
173+
string memory validator
174+
) external view returns (DecCoin[] memory);
150175
```
151176

152177
Returns rewards for a specific delegator-validator pair.
@@ -165,7 +190,9 @@ Returns rewards for a specific delegator-validator pair.
165190
#### delegatorValidators
166191

167192
```solidity
168-
function delegatorValidators(address delegator) external view returns (string[] memory)
193+
function delegatorValidators(
194+
address delegator
195+
) external view returns (string[] memory);
169196
```
170197

171198
Lists all validators from which a delegator can claim rewards.
@@ -183,7 +210,9 @@ Lists all validators from which a delegator can claim rewards.
183210
#### delegatorWithdrawAddress
184211

185212
```solidity
186-
function delegatorWithdrawAddress(address delegator) external view returns (string memory)
213+
function delegatorWithdrawAddress(
214+
address delegator
215+
) external view returns (string memory);
187216
```
188217

189218
Returns the configured withdraw address for a delegator.
@@ -201,7 +230,7 @@ Returns the configured withdraw address for a delegator.
201230
#### communityPool
202231

203232
```solidity
204-
function communityPool() external view returns (DecCoin[] memory)
233+
function communityPool() external view returns (DecCoin[] memory);
205234
```
206235

207236
Returns the current balance of the community pool.
@@ -215,7 +244,9 @@ Returns the current balance of the community pool.
215244
#### validatorCommission
216245

217246
```solidity
218-
function validatorCommission(string memory validator) external view returns (DecCoin[] memory)
247+
function validatorCommission(
248+
string memory validator
249+
) external view returns (DecCoin[] memory);
219250
```
220251

221252
Returns accumulated commission for a validator.
@@ -233,7 +264,9 @@ Returns accumulated commission for a validator.
233264
#### validatorDistributionInfo
234265

235266
```solidity
236-
function validatorDistributionInfo(string memory validator) external view returns (DistInfo memory)
267+
function validatorDistributionInfo(
268+
string memory validator
269+
) external view returns (DistInfo memory);
237270
```
238271

239272
Returns comprehensive distribution information for a validator.
@@ -251,7 +284,9 @@ Returns comprehensive distribution information for a validator.
251284
#### validatorOutstandingRewards
252285

253286
```solidity
254-
function validatorOutstandingRewards(string memory validator) external view returns (DecCoin[] memory)
287+
function validatorOutstandingRewards(
288+
string memory validator
289+
) external view returns (DecCoin[] memory);
255290
```
256291

257292
Returns outstanding (undistributed) rewards for a validator.
@@ -269,7 +304,15 @@ Returns outstanding (undistributed) rewards for a validator.
269304
#### validatorSlashes
270305

271306
```solidity
272-
function validatorSlashes(string memory validator, uint64 startingHeight, uint64 endingHeight, PageRequest memory pageRequest) external view returns (ValidatorSlashEvent[] memory, PageResponse memory)
307+
function validatorSlashes(
308+
string memory validator,
309+
uint64 startingHeight,
310+
uint64 endingHeight,
311+
PageRequest memory pageRequest
312+
) external view returns (
313+
ValidatorSlashEvent[] memory,
314+
PageResponse memory
315+
);
273316
```
274317

275318
Returns slashing events for a validator within a height range.

precompiles/staking/README.md

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,45 @@ The precompile uses standard gas configuration for storage operations.
192192
## Events
193193

194194
```solidity
195-
event CreateValidator(address indexed validatorAddress, uint256 value);
196-
event EditValidator(address indexed validatorAddress, int256 commissionRate, int256 minSelfDelegation);
197-
event Delegate(address indexed delegatorAddress, string indexed validatorAddress, uint256 amount, uint256 shares);
198-
event Unbond(address indexed delegatorAddress, string indexed validatorAddress, uint256 amount, int64 completionTime);
199-
event Redelegate(address indexed delegatorAddress, string indexed validatorSrcAddress, string indexed validatorDstAddress, uint256 amount, int64 completionTime);
200-
event CancelUnbondingDelegation(address indexed delegatorAddress, string indexed validatorAddress, uint256 amount, uint256 creationHeight);
195+
event CreateValidator(
196+
address indexed validatorAddress,
197+
uint256 value
198+
);
199+
200+
event EditValidator(
201+
address indexed validatorAddress,
202+
int256 commissionRate,
203+
int256 minSelfDelegation
204+
);
205+
206+
event Delegate(
207+
address indexed delegatorAddress,
208+
string indexed validatorAddress,
209+
uint256 amount,
210+
uint256 shares
211+
);
212+
213+
event Unbond(
214+
address indexed delegatorAddress,
215+
string indexed validatorAddress,
216+
uint256 amount,
217+
int64 completionTime
218+
);
219+
220+
event Redelegate(
221+
address indexed delegatorAddress,
222+
string indexed validatorSrcAddress,
223+
string indexed validatorDstAddress,
224+
uint256 amount,
225+
int64 completionTime
226+
);
227+
228+
event CancelUnbondingDelegation(
229+
address indexed delegatorAddress,
230+
string indexed validatorAddress,
231+
uint256 amount,
232+
uint256 creationHeight
233+
);
201234
```
202235

203236
## Security Considerations

0 commit comments

Comments
 (0)