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

Update Solidity API docs #36

Merged
merged 7 commits into from
Jun 29, 2023
87 changes: 82 additions & 5 deletions docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,89 @@
* [Get Started (PRE Mainnet)](app-development/threshold-access-control-tac/advanced-usage/proxy-re-encryption.md)
* [Contribution Guide](app-development/contribution-guide.md)
* [Staking Contract and DAO](app-development/staking-contract-and-dao/README.md)
* [Random Beacon API](app-development/staking-contract-and-dao/staking-contract-and-dao-api/generated-docs/index.md)
* [Staking Contract and DAO API](app-development/staking-contract-and-dao/staking-contract-and-dao-api/README.md)
* [BaseTokenholderGovernor](app-development/staking-contract-and-dao/staking-contract-and-dao-api/generated-docs/governance/BaseTokenholderGovernor.md)
* [Checkpoints](app-development/staking-contract-and-dao/staking-contract-and-dao-api/generated-docs/governance/Checkpoints.md)
* [GovernorParameters](app-development/staking-contract-and-dao/staking-contract-and-dao-api/generated-docs/governance/GovernorParameters.md)
* [IApplication](app-development/staking-contract-and-dao/staking-contract-and-dao-api/generated-docs/staking/IApplication.md)
* [ILegacyTokenStaking](app-development/staking-contract-and-dao/staking-contract-and-dao-api/generated-docs/staking/ILegacyTokenStaking.md)
* [IStaking](app-development/staking-contract-and-dao/staking-contract-and-dao-api/generated-docs/staking/IStaking.md)
* [IVotesHistory](app-development/staking-contract-and-dao/staking-contract-and-dao-api/generated-docs/governance/IVotesHistory.md)
* [KeepStake](app-development/staking-contract-and-dao/staking-contract-and-dao-api/generated-docs/staking/KeepStake.md)
* [PercentUtils](app-development/staking-contract-and-dao/staking-contract-and-dao-api/generated-docs/utils/PercentUtils.md)
* [ProxyAdminWithDeputy](app-development/staking-contract-and-dao/staking-contract-and-dao-api/generated-docs/governance/ProxyAdminWithDeputy.md)
* [SafeTUpgradeable](app-development/staking-contract-and-dao/staking-contract-and-dao-api/generated-docs/utils/SafeTUpgradeable.md)
* [StakerGovernor](app-development/staking-contract-and-dao/staking-contract-and-dao-api/generated-docs/governance/StakerGovernor.md)
* [StakerGovernorVotes](app-development/staking-contract-and-dao/staking-contract-and-dao-api/generated-docs/governance/StakerGovernorVotes.md)
* [T](app-development/staking-contract-and-dao/staking-contract-and-dao-api/generated-docs/token/T.md)
* [TokenholderGovernor](app-development/staking-contract-and-dao/staking-contract-and-dao-api/generated-docs/governance/TokenholderGovernor.md)
* [TokenholderGovernorVotes](app-development/staking-contract-and-dao/staking-contract-and-dao-api/generated-docs/governance/TokenholderGovernorVotes.md)
* [TokenStaking](app-development/staking-contract-and-dao/staking-contract-and-dao-api/generated-docs/staking/TokenStaking.md)
* [VendingMachine](app-development/staking-contract-and-dao/staking-contract-and-dao-api/generated-docs/vendingVendingMachine.md)
* [Random Beacon](app-development/random-beacon/README.md)
* [Random Beacon API](app-development/random-beacon/random-beacon-api/generated-docs/index.md)
* [TBTCv2](app-development/tbtc-v2/README.md)
* [ECDSA API](app-development/tbtc-v2/ecdsa-api/generated-docs/index.md)
* [TBTCv2 API](app-development/tbtc-v2/tbtc-v2-api/generated-docs/index.md)
* [Random Beacon API](app-development/random-beacon/random-beacon-api/README.md)
* [AltBn128](app-development/random-beacon/random-beacon-api/generated-docs/libraries/AltBn128.md)
* [BeaconAuthorization](app-development/random-beacon/random-beacon-api/generated-docs/libraries/BeaconAuthorization.md)
* [BeaconDkg](app-development/random-beacon/random-beacon-api/generated-docs/libraries/BeaconDkg.md)
* [BeaconDkgValidator](app-development/random-beacon/random-beacon-api/generated-docs/BeaconDkgValidator.md)
* [BeaconInactivity](app-development/random-beacon/random-beacon-api/generated-docs/libraries/BeaconInactivity.md)
* [BLS](app-development/random-beacon/random-beacon-api/generated-docs/libraries/BLS.md)
* [BytesLib](app-development/random-beacon/random-beacon-api/generated-docs/libraries/BytesLib.md)
* [Callback](app-development/random-beacon/random-beacon-api/generated-docs/libraries/Callback.md)
* [Governable](app-development/random-beacon/random-beacon-api/generated-docs/Governable.md)
* [Groups](app-development/random-beacon/random-beacon-api/generated-docs/libraries/Groups.md)
* [IRandomBeacon](app-development/random-beacon/random-beacon-api/generated-docs/api/IRandomBeacon.md)
* [IRandomBeaconConsumer](app-development/random-beacon/random-beacon-api/generated-docs/api/IRandomBeaconConsumer.md)
* [ModUtils](app-development/random-beacon/random-beacon-api/generated-docs/libraries/ModUtils.md)
* [RandomBeacon](app-development/random-beacon/random-beacon-api/generated-docs/RandomBeacon.md)
* [RandomBeaconChaosnet](app-development/random-beacon/random-beacon-api/generated-docs/RandomBeaconChaosnet.md)
* [RandomBeaconGovernance](app-development/random-beacon/random-beacon-api/generated-docs/RandomBeaconGovernance.md)
* [Reimbursable](app-development/random-beacon/random-beacon-api/generated-docs/Reimbursable.md)
* [ReimbursementPool](app-development/random-beacon/random-beacon-api/generated-docs/ReimbursementPool.md)
* [Relay](app-development/random-beacon/random-beacon-api/generated-docs/libraries/Relay.md)
* [tBTC](app-development/tbtc-v2/README.md)
* [ECDSA API](app-development/tbtc-v2/ecdsa-api/README.md)
* [EcdsaAuthorization](app-development/tbtc-v2/ecdsa-api/generated-docs/libraries/EcdsaAuthorization.md)
* [EcdsaDkg](app-development/tbtc-v2/ecdsa-api/generated-docs/libraries/EcdsaDkg.md)
* [EcdsaDkgValidator](app-development/tbtc-v2/ecdsa-api/generated-docs/EcdsaDkgValidator.md)
* [EcdsaInactivity](app-development/tbtc-v2/ecdsa-api/generated-docs/libraries/EcdsaInactivity.md)
* [IWalletOwner](app-development/tbtc-v2/ecdsa-api/generated-docs/api/IWalletOwner.md)
* [IWalletRegistry](app-development/tbtc-v2/ecdsa-api/generated-docs/api/IWalletRegistry.md)
* [WalletRegistry](app-development/tbtc-v2/ecdsa-api/generated-docs/WalletRegistry.md)
* [WalletRegistryGovernance](app-development/tbtc-v2/ecdsa-api/generated-docs/WalletRegistryGovernance.md)
* [Wallets](app-development/tbtc-v2/ecdsa-api/generated-docs/libraries/Wallets.md)
* [Bridge API](app-development/tbtc-v2/tbtc-v2-api/README.md)
* [Bank](app-development/tbtc-v2/tbtc-v2-api/generated-docs/bank/Bank.md)
* [BitcoinTx](app-development/tbtc-v2/tbtc-v2-api/generated-docs/bridge/BitcoinTx.md)
* [Bridge](app-development/tbtc-v2/tbtc-v2-api/generated-docs/bridge/Bridge.md)
* [BridgeGovernance](app-development/tbtc-v2/tbtc-v2-api/generated-docs/bridge/BridgeGovernance.md)
* [BridgeGovernanceParameters](app-development/tbtc-v2/tbtc-v2-api/generated-docs/bridge/BridgeGovernanceParameters.md)
* [BridgeState](app-development/tbtc-v2/tbtc-v2-api/generated-docs/bridge/BridgeState.md)
* [Deposit](app-development/tbtc-v2/tbtc-v2-api/generated-docs/bridge/Deposit.md)
* [DepositSweep](app-development/tbtc-v2/tbtc-v2-api/generated-docs/bridge/DepositSweep.md)
* [DonationVault](app-development/tbtc-v2/tbtc-v2-api/generated-docs/vault/DonationVault.md)
* [EcdsaLib](app-development/tbtc-v2/tbtc-v2-api/generated-docs/bridge/EcdsaLib.md)
* [Fraud](app-development/tbtc-v2/tbtc-v2-api/generated-docs/bridge/Fraud.md)
* [GovernanceUtils](app-development/tbtc-v2/tbtc-v2-api/generated-docs/GovernanceUtils.md)
* [Heartbeat](app-development/tbtc-v2/tbtc-v2-api/generated-docs/bridge/Heartbeat.md)
* [IReceiveBalanceApproval](app-development/tbtc-v2/tbtc-v2-api/generated-docs/bank/IReceiveBalanceApproval.md)
* [IRelay](app-development/tbtc-v2/tbtc-v2-api/generated-docs/bridge/IRelay.md)
* [IVault](app-development/tbtc-v2/tbtc-v2-api/generated-docs/vault/IVault.md)
* [L2TBTC](app-development/tbtc-v2/tbtc-v2-api/generated-docs/l2/L2TBTC.md)
* [L2WormholeGateway](app-development/tbtc-v2/tbtc-v2-api/generated-docs/l2/L2WormholeGateway.md)
* [LightRelay](app-development/tbtc-v2/tbtc-v2-api/generated-docs/relay/LightRelay.md)
* [LightRelayMaintainerProxy](app-development/tbtc-v2/tbtc-v2-api/generated-docs/relay/LightRelayMaintainerProxy.md)
* [MaintainerProxy](app-development/tbtc-v2/tbtc-v2-api/generated-docs/maintainer/MaintainerProxy.md)
* [MovingFunds](app-development/tbtc-v2/tbtc-v2-api/generated-docs/bridge/MovingFunds.md)
* [Redemption](app-development/tbtc-v2/tbtc-v2-api/generated-docs/bridge/Redemption.md)
* [TBTC](app-development/tbtc-v2/tbtc-v2-api/generated-docs/token/TBTC.md)
* [TBTCOptimisticMinting](app-development/tbtc-v2/tbtc-v2-api/generated-docs/vault/TBTCOptimisticMinting.md)
* [TBTCVault](app-development/tbtc-v2/tbtc-v2-api/generated-docs/vault/TBTCVault.md)
* [VendingMachine](app-development/tbtc-v2/tbtc-v2-api/generated-docs/bridge/VendingMachine.md)
* [VendingMachineV2](app-development/tbtc-v2/tbtc-v2-api/generated-docs/bridge/VendingMachineV2.md)
* [VendingMachineV3](app-development/tbtc-v2/tbtc-v2-api/generated-docs/bridge/VendingMachineV3.md)
* [WalletCoordinator](app-development/tbtc-v2/tbtc-v2-api/generated-docs/bridge/WalletCoordinator.md)
* [Wallets](app-development/tbtc-v2/tbtc-v2-api/generated-docs/bridge/Wallets.md)

## Resources

Expand Down
42 changes: 42 additions & 0 deletions docs/app-development/random-beacon/random-beacon-api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Random Beacon API

You can learn about APIs of contracts related to the Random Beacon under the
following links:
Comment on lines +3 to +4
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This copy could be a bit better. We could point the reader to the repository, say that the code documentation was generated automatically based on the docs in the code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#37


[AltBn128](./generated-docs/libraries/AltBn128.md)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be better to have them as a bullet list?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question to all README.md files in this PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#37


[BeaconAuthorization](./generated-docs/libraries/BeaconAuthorization.md)

[BeaconDkg](./generated-docs/libraries/BeaconDkg.md)

[BeaconDkgValidator](./generated-docs/BeaconDkgValidator.md)

[BeaconInactivity](./generated-docs/libraries/BeaconInactivity.md)

[BLS](./generated-docs/libraries/BLS.md)

[BytesLib](./generated-docs/libraries/BytesLib.md)

[Callback](./generated-docs/libraries/Callback.md)

[Governable](./generated-docs/Governable.md)

[Groups](./generated-docs/libraries/Groups.md)

[IRandomBeacon](./generated-docs/api/IRandomBeacon.md)

[IRandomBeaconConsumer](./generated-docs/api/IRandomBeaconConsumer.md)

[ModUtils](./generated-docs/libraries/ModUtils.md)

[RandomBeacon](./generated-docs/RandomBeacon.md)

[RandomBeaconChaosnet](./generated-docs/RandomBeaconChaosnet.md)

[RandomBeaconGovernance](./generated-docs/RandomBeaconGovernance.md)

[Reimbursable](./generated-docs/Reimbursable.md)

[ReimbursementPool](./generated-docs/ReimbursementPool.md)

[Relay](./generated-docs/libraries/Relay.md)
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
# Solidity API

## BeaconDkgValidator

DKGValidator allows performing a full validation of DKG result,
including checking the format of fields in the result, declared
selected group members, and signatures of operators supporting the
result. The operator submitting the result should perform the
validation using a free contract call before submitting the result
to ensure their result is valid and can not be challenged. All other
network operators should perform validation of the submitted result
using a free contract call and challenge the result if the
validation fails.

### groupSize

```solidity
uint256 groupSize
```

Size of a group in the threshold relay.

### groupThreshold

```solidity
uint256 groupThreshold
```

The minimum number of group members needed to interact according to
the protocol to produce a relay entry. The adversary can not learn
anything about the key as long as it does not break into
groupThreshold+1 of members.

### activeThreshold

```solidity
uint256 activeThreshold
```

The minimum number of active and properly behaving group members
during the DKG needed to accept the result. This number is higher
than `groupThreshold` to keep a safety margin for members becoming
inactive after DKG so that the group can still produce a relay
entry.

### signatureByteSize

```solidity
uint256 signatureByteSize
```

Size in bytes of a single signature produced by operator supporting
DKG result.

### sortitionPool

```solidity
contract SortitionPool sortitionPool
```

### constructor

```solidity
constructor(contract SortitionPool _sortitionPool) public
```

### validate

```solidity
function validate(struct BeaconDkg.Result result, uint256 seed, uint256 startBlock) external view returns (bool isValid, string errorMsg)
```

Performs a full validation of DKG result, including checking the
format of fields in the result, declared selected group members,
and signatures of operators supporting the result.

#### Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| result | struct BeaconDkg.Result | |
| seed | uint256 | seed used to start the DKG and select group members |
| startBlock | uint256 | DKG start block |

#### Return Values

| Name | Type | Description |
| ---- | ---- | ----------- |
| isValid | bool | true if the result is valid, false otherwise |
| errorMsg | string | validation error message; empty for a valid result |

### validateFields

```solidity
function validateFields(struct BeaconDkg.Result result) public pure returns (bool isValid, string errorMsg)
```

Performs a static validation of DKG result fields: lengths,
ranges, and order of arrays.

#### Return Values

| Name | Type | Description |
| ---- | ---- | ----------- |
| isValid | bool | true if the result is valid, false otherwise |
| errorMsg | string | validation error message; empty for a valid result |

### validateGroupMembers

```solidity
function validateGroupMembers(struct BeaconDkg.Result result, uint256 seed) public view returns (bool)
```

Performs validation of group members as declared in DKG
result against group members selected by the sortition pool.

#### Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| result | struct BeaconDkg.Result | |
| seed | uint256 | seed used to start the DKG and select group members |

#### Return Values

| Name | Type | Description |
| ---- | ---- | ----------- |
| [0] | bool | true if group members matches; false otherwise |

### validateSignatures

```solidity
function validateSignatures(struct BeaconDkg.Result result, uint256 startBlock) public view returns (bool)
```

Performs validation of signatures supplied in DKG result.
Note that this function does not check if addresses which
supplied signatures supporting the result are the ones selected
to the group by sortition pool. This function should be used
together with `validateGroupMembers`.

#### Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| result | struct BeaconDkg.Result | |
| startBlock | uint256 | DKG start block |

#### Return Values

| Name | Type | Description |
| ---- | ---- | ----------- |
| [0] | bool | true if group members matches; false otherwise |

### validateMembersHash

```solidity
function validateMembersHash(struct BeaconDkg.Result result) public pure returns (bool)
```

Performs validation of hashed group members that actively took
part in DKG.

#### Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| result | struct BeaconDkg.Result | DKG result |

#### Return Values

| Name | Type | Description |
| ---- | ---- | ----------- |
| [0] | bool | true if result's group members hash matches with the one that is challenged. |

Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Solidity API

## Governable

Governable contract.

A constructor is not defined, which makes the contract compatible with
upgradable proxies. This requires calling explicitly `_transferGovernance`
function in a child contract.

### governance

```solidity
address governance
```

### GovernanceTransferred

```solidity
event GovernanceTransferred(address oldGovernance, address newGovernance)
```

### onlyGovernance

```solidity
modifier onlyGovernance()
```

### transferGovernance

```solidity
function transferGovernance(address newGovernance) external virtual
```

Transfers governance of the contract to `newGovernance`.

### _transferGovernance

```solidity
function _transferGovernance(address newGovernance) internal virtual
```

Loading