Abstract base class for contracts that depend on other contracts whose addresses can change.
+
The AddressUpdater contract keeps a list of addresses for all unique and special
+platform contracts. By inheriting from AddressUpdatable a contract will receive updates
+if any of the platform contract addresses change.
+
A contract's address changes when it is redeployed, so AddressUpdatable offers a way
+to keep up to date with the latest address for all dependencies.
Keeps track of the current address for all unique and special platform contracts.
+
This contract keeps a list of addresses that gets updated by governance every time
+any of the tracked contracts is redeployed.
+This list is then used by the FlareContractRegistry, and also by AddressUpdatable
+to inform all dependent contracts of any address change.
Delete balance checkpoints that expired (i.e. are before cleanupBlockNumber).
+Method can only be called from the cleanerContract (which may be a proxy to external cleaners).
Delete total supply cache entry that expired (i.e. is before cleanupBlockNumber).
+Method can only be called from the cleanerContract (which may be a proxy to external cleaners).
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_blockNumber
+
uint256
+
the block number for which total supply value was cached
+
+
+
+
+
+
+
Returns
+
Type
+
Description
+
+
+
+
+
[0]
+
uint256
+
the number of cache entries deleted (always 0 or 1)
Delete total supply checkpoints that expired (i.e. are before cleanupBlockNumber).
+Method can only be called from the cleanerContract (which may be a proxy to external cleaners).
Gets the addresses of recipients allowed to receive rewards on behalf of an account.
+Beside these, the owner of the rewards is always authorized.
+See setAllowedClaimRecipients.
The percentage of voting power to be delegated to each delegatee, expressed in basis points (1/100 of one percent). Total of all _bips values must be lower than 10000.
Delegates a percentage of the caller's
+PDA's voting power to another address.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_to
+
address
+
The address of the recipient.
+
+
+
_bips
+
uint256
+
The percentage of voting power to be delegated expressed in basis points (1/100 of one percent). Not cumulative: Every call resets the delegation value. A value of 0 revokes delegation.
When using automatic claiming, all airdrops and FTSO rewards will be sent to the owner's account.
+Rewards accrued by the PDA will no longer be automatically claimed.
Gets the Personal Delegation Account (PDA) for
+a list of accounts for which an executor is claiming.
+Returns owner address instead if the PDA is not created yet or not enabled.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_executor
+
address
+
Executor to query.
+
+
+
_owners
+
address[]
+
Array of reward owners which must have set _executor as their executor.
+
+
+
+
+
+
+
Returns
+
Type
+
Description
+
+
+
+
+
_recipients
+
address[]
+
Addresses which will receive the claimed rewards. Can be the reward owners or their PDAs.
Registers the caller as an executor and sets its initial fee value.
+
If the executor was already registered, this method only updates the fee, which will take effect after
+feeValueUpdateOffset reward epochs have elapsed.
Revokes all delegation from the caller's PDA
+to a given account at a given block.
+
Only affects the reads via votePowerOfAtCached() in the specified block.
+
This method should be used only to prevent rogue delegate voting in the current voting block.
+To stop delegating use delegate with percentage of 0 or undelegateAll.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_who
+
address
+
The account to revoke.
+
+
+
_blockNumber
+
uint256
+
Block number where the revoking will take place. Must be in the past.
Allows the caller to transfer ERC-20 tokens from their
+PDA to the owner account.
+
The main use case is to move ERC-20 tokes received by mistake (by an airdrop, for example) out of the PDA
+and into the main account, where they can be more easily managed.
+
Reverts if the target token is the WNat contract: use method withdraw for that.
Prevents a contract from calling itself, directly or indirectly.
+Calling a nonReentrant function from another nonReentrant
+function is not supported. It is possible to prevent this from happening
+by making the nonReentrant function external, and make it call a
+private function that does the actual work.
This code (intended to be called from an implementor factory contract) will allow you to install a master copy of a
+contract, then easily (cheaply) create clones with separate state.
+The deployed bytecode just delegates all calls to the master contract address.
Adds delegation capabilities to tokens. This contract orchestrates interaction between
+managing a delegation and the vote power allocations that result.
Delete explicit delegation checkpoints that expired (i.e. are before cleanupBlockNumber).
+Method can only be called from the cleanerContract (which may be a proxy to external cleaners).
Delete percentage delegation checkpoints that expired (i.e. are before cleanupBlockNumber).
+Method can only be called from the cleanerContract (which may be a proxy to external cleaners).
Delete revocation entry that expired (i.e. is before cleanupBlockNumber).
+Method can only be called from the cleanerContract (which may be a proxy to external cleaners).
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_from
+
address
+
Delegator address.
+
+
+
_to
+
address
+
Delegatee address.
+
+
+
_blockNumber
+
uint256
+
Block number for which total supply value was cached.
+
+
+
+
+
+
+
Returns
+
Type
+
Description
+
+
+
+
+
[0]
+
uint256
+
Number of revocation entries deleted (always 0 or 1).
Delete vote power cache entry that expired (i.e. is before cleanupBlockNumber).
+Method can only be called from the cleanerContract (which may be a proxy to external cleaners).
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_owner
+
address
+
Vote power owner account address.
+
+
+
_blockNumber
+
uint256
+
Block number for which total supply value was cached.
Delete vote power checkpoints that expired (i.e. are before cleanupBlockNumber).
+Method can only be called from the cleanerContract (which may be a proxy to external cleaners).
This contract exists to coordinate regular daemon-like polling of contracts
+that are registered to receive said polling. The trigger method is called by the
+validator right at the end of block state transition.
This constructor should contain no code as this contract is pre-loaded into the genesis block.
+ The super constructor is called for testing convenience.
Register contracts to be polled by the daemon process.
+
A gas limit of zero will set no limit for the contract but the validator has an overall
+ limit for the trigger method.
+If any registrations already exist, they will be unregistered.
+Contracts will be daemonized in the order in which presented via the _registrations array.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_registrations
+
struct FlareDaemon.Registration[]
+
An array of Registration structures of IFlareDaemonize contracts to daemonize and gas limits for each contract.
An instance of this contract is created for each tracked asset, and typically
+accessed through the FtsoRegistry.
+Data providers do not access the Ftso instances directly either, and use the
+PriceSubmitter contract instead.
Forces finalization of a price epoch, calculating the median price from trusted addresses only.
+
Used as a fallback method, for example, due to an unexpected error during normal epoch finalization or
+because the ftsoManager enabled the fallback mode.
Returns the random number for the previous price epoch, obtained from the random numbers
+provided by all data providers along with their data submissions.
Returns the random number used in a specific past epoch, obtained from the random numbers
+provided by all data providers along with their data submissions.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_epochId
+
uint256
+
ID of the queried epoch. Current epoch cannot be queried, and the previous epoch is constantly updated as data providers reveal their prices and random numbers. Only the last 50 epochs can be queried and there is no bounds checking for this parameter. Out-of-bounds queries return undefined values.
Adds a list of FTSOs to the list of managed FTSOs, to support new price pairs.
+All FTSOs in a multi-asset FTSO must be managed by the same FTSO manager.
Implement this function to receive a trigger from the FlareDaemon.
+The trigger method is called by the validator right at the end of block state transition.
Returns timing information for the current price epoch.
+All intervals are half-closed: end time is not included.
+All timestamps are in seconds since UNIX epoch.
+
See the FTSO page
+for information about the different submission phases.
Returns information regarding the currently unprocessed price epoch.
+This epoch is not necessarily the last one, in case the network halts for some
+time due to validator node problems, for example.
+
+
+
+
Returns
+
Type
+
Description
+
+
+
+
+
_lastUnprocessedPriceEpoch
+
uint256
+
ID of the price epoch that is currently waiting finalization.
+
+
+
_lastUnprocessedPriceEpochRevealEnds
+
uint256
+
When that price epoch can be finalized, in seconds since UNIX epoch.
+
+
+
_lastUnprocessedPriceEpochInitialized
+
bool
+
Whether this price epoch has been already initialized and therefore it must be finalized before the corresponding reward epoch can be finalized.
Replaces one FTSO with another with the same symbol.
+All FTSOs in a multi-asset FTSO must be managed by the same FTSO manager.
+Deactivates the old FTSO.
Replaces a list of FTSOs with other FTSOs with the same symbol.
+All FTSOs in a multi-asset FTSO must be managed by the same FTSO manager.
+Deactivates the old FTSOs.
Sets the reward epoch duration.
+Only governance can call this method.
+
If the reward epoch is very short and the expiry offset is very long, the list of reward epochs
+to be checked becomes very long. Therefore reward epoch time has to be capped to expiry offset.
This function will be called after an error is caught in daemonize.
+It will switch the contract to a simpler fallback mode, which hopefully works when full mode doesn't.
+Not every contract needs to support fallback mode (FtsoManager does), so this method may be empty.
+Switching back to normal mode is left to the contract (typically a governed method call).
+This function may be called due to low-gas error, so it shouldn't use more than ~30.000 gas.
Get the history of FTSOs for given index.
+If there are less then MAX_HISTORY_LENGTH the remaining addresses will be 0 addresses.
+Reverts if index is not supported.
Get array of all FTSO contracts for all supported asset indices.
+The index of FTSO in returned array does not necessarily correspond to the asset's index.
+Due to deletion, some indices might be unsupported.
+
Use getSupportedIndicesAndFtsos to retrieve pairs of correct indices and FTSOs,
+where possible "null" holes are readily apparent.
Removes the FTSO and keeps part of the history.
+Reverts if the provided address is not supported.
+
From now on, the index this asset was using is "reserved" and cannot be used again.
+It will not be returned in any list of currently supported assets.
Accrue unearned rewards for a given price epoch.
+Typically done when the FTSO is in fallback mode or because of insufficient vote power.
+Simply accrue them so they will not be distributed and will be burned later.
+
The amount of rewards that will be burned is calculated in the same way as in distributeRewards.
Allows claiming rewards simultaneously for a list of reward owners and all unclaimed epochs before the
+specified one.
+
This is meant as a convenience all-in-one reward claiming method to be used both by reward owners and
+registered executors.
+It performs a series of operations, besides claiming rewards:
+
+
+
If a reward owner has enabled its
+Personal Delegation Account, rewards are also
+claimed for the PDA and the total claimed amount is sent to that PDA.
+Otherwise, the claimed amount is sent to the reward owner's account.
+
+
+
Claimed amount is automatically wrapped through the WNat contract.
+
+
+
If the caller is a registered executor with a non-zero fee, the fee is paid to the executor for each claimed
+address.
+
+
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_rewardOwners
+
address[]
+
List of reward owners to claim for.
+
+
+
_rewardEpoch
+
uint256
+
Last reward epoch ID to claim for. All previous epochs with pending rewards will be claimed too.
Allows the caller to claim rewards for a reward owner.
+The caller does not have to be the owner of the rewards, but must be approved by the owner to claim on his
+behalf by using setClaimExecutors on the claimSetupManager.
+
This function is intended to be used to claim rewards in case of delegation by percentage.
+Reverts if msg.sender is delegating by amount.
+
Anybody can call this method, but rewards can only be sent to the reward owner, therefore no funds can be
+stolen. However, by limiting the authorized callers, the owner can control the timing of the calls.
+
When the reward owner is the caller, rewards can be sent to any recipient set by setAllowedClaimRecipients on
+the claimSetupManager.
+The reward owner's Personal Delegation Account
+is always an authorized recipient.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_rewardOwner
+
address
+
Address of the reward owner.
+
+
+
_recipient
+
address payable
+
Address to transfer claimed rewards to.
+
+
+
_rewardEpoch
+
uint256
+
Last reward epoch to claim for. All previous epochs with pending rewards will be claimed too.
+
+
+
_wrap
+
bool
+
Whether claimed rewards should be wrapped through the WNat contract before transferring them to the _recipient. This parameter is offered as a convenience.
Allows the caller to claim rewards for a reward owner from specific data providers.
+The caller does not have to be the owner of the rewards, but must be approved by the owner to claim on his
+behalf by using setClaimExecutors on the claimSetupManager.
+
This function is intended to be used to claim rewards in case of delegation by amount (explicit delegation).
+Reverts if msg.sender is delegating by percentage.
+
Anybody can call this method, but rewards can only be sent to the reward owner, therefore no funds can be
+stolen. However, by limiting the authorized callers, the owner can control the timing of the calls.
+
When the reward owner is the caller, rewards can be sent to any recipient set by setAllowedClaimRecipients on
+the claimSetupManager.
+The reward owner's Personal Delegation Account
+is always an authorized recipient.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_rewardOwner
+
address
+
Address of the reward owner.
+
+
+
_recipient
+
address payable
+
Address to transfer claimed rewards to.
+
+
+
_rewardEpochs
+
uint256[]
+
Array of reward epoch IDs to claim for.
+
+
+
_dataProviders
+
address[]
+
Array of addresses of the data providers to claim the reward from.
+
+
+
_wrap
+
bool
+
Whether claimed rewards should be wrapped through the WNat contract before transferring them to the _recipient. This parameter is offered as a convenience.
Reverts if msg.sender is delegating by amount.
+Claims for all unclaimed reward epochs to the 'max(_rewardEpochs)'.
+Retained for backward compatibility.
Allows the caller to claim rewards from specific data providers.
+This function is intended to be used to claim rewards in case of delegation by amount.
Collects funds from expired reward epoch and calculates totals.
+
Triggered by ftsoManager on finalization of a reward epoch.
+Operation is irreversible: when some reward epoch is closed according to current
+settings, it cannot be reopened even if new parameters would
+allow it, because nextRewardEpochToExpire in ftsoManager never decreases.
Distributes price epoch rewards to data provider accounts, according to input parameters.
+Must be called with totalWeight > 0 and addresses.length > 0.
+
The amount of rewards for a given price epoch ID are calculated in FtsoRewardManager from
+priceEpochDurationSeconds, priceEpochEndTime and inflation authorization data
+(see _getTotalPriceEpochRewardWei in FtsoRewardManager.
+Then each data provider address is given a portion of this amount according to corresponding weight
+and total sum of weights.
+
Parameters epochId and ftso are only needed so they can be passed onto the emitted event.
Returns the reward epoch range for which rewards can be claimed.
+Rewards outside this range are unclaimable, either because they have expired or because the reward epoch is
+still ongoing.
Returns the initial reward epoch ID for this reward manager contract.
+This corresponds to the oldest reward epoch with claimable rewards in the previous reward manager when this
+one took over.
+Set by governance through setInitialRewardData.
Total amount of funds ever locked in the token pool (wei). _lockedFundsWei - _totalClaimedWei is the amount currently locked and outside the circulating supply.
Returns information on unclaimed rewards for a given data provider and epoch.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_rewardEpoch
+
uint256
+
Queried reward epoch ID.
+
+
+
_dataProvider
+
address
+
Address of the queried data provider.
+
+
+
+
+
+
+
Returns
+
Type
+
Description
+
+
+
+
+
_amount
+
uint256
+
Amount available to be claimed, in wei.
+
+
+
_weight
+
uint256
+
Portion of total vote power used in this reward epoch that has not yet claimed its reward, in BIPS. It decreases to 0 when all data providers have claimed their rewards.
Copy initial reward data from oldFtsoRewardManager before starting up this new reward manager.
+Should be called at the time of switching to the new reward manager, can be called only once, and only
+by governance.
Sets new ftso reward manager which will take over closing expired reward epochs
+Should be called at the time of switching to the new reward manager, can be called only once, and only
+by governance.
Prevents a contract from calling itself, directly or indirectly.
+Calling a nonReentrant function from another nonReentrant
+function is not supported. It is possible to prevent this from happening
+by making the nonReentrant function external, and make it call a
+private function that does the actual work.
Only the reward owner and its authorized executors can call this method.
+Executors can only send rewards to authorized recipients.
+See ClaimSetupManager.
Gets the addresses of the accounts that are allowed to execute the timelocked governance calls,
+once the timelock period expires.
+Executors can be changed without a hard fork, via a normal governance call.
Set the addresses of the accounts that are allowed to execute the timelocked governance calls
+once the timelock period expires.
+It isn't very dangerous to allow for anyone to execute timelocked calls, but we reserve the right to
+make sure the timing of the execution is under control.
+Can only be called by the governance.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_newExecutors
+
address[]
+
New list of allowed executors. The previous list is replaced.
Delete governance vote power checkpoints that expired (i.e. are before cleanupBlockNumber).
+Method can only be called from the cleanerContract (which may be a proxy to external cleaners).
Delete delegates checkpoints that expired (i.e. are before cleanupBlockNumber).
+Method can only be called from the cleanerContract (which may be a proxy to external cleaners).
Set the cleanup block number.
+Historic data for the blocks before cleanupBlockNumber can be erased.
+History before that block should never be used since it can be inconsistent.
+In particular, cleanup block number must be lower than the current vote power block.
The VPToken (or some other contract) that owns this GovernanceVotePower.
+All state changing methods may be called only from this address.
+This is because original msg.sender is typically sent in a parameter
+and we must make sure that it cannot be faked by directly calling
+GovernanceVotePower methods.
Defines behaviors for governed contracts that have their governor set at genesis.
+
This contract enforces a fixed governance address when the constructor
+is not executed on a contract (for instance when directly loaded to the genesis block).
+This is required to fix governance on a contract when the network starts, at such point
+where theoretically no accounts yet exist, and leaving it ungoverned could result in a race
+to claim governance by an unauthorized address.
Abstract base class that defines behaviors for governed contracts.
+
This class is abstract so that specific behaviors can be defined for the constructor.
+Contracts should not be left ungoverned, but not all contract will have a constructor
+(for example those pre-defined in genesis).
Gets the addresses of recipients allowed to receive rewards on behalf of an account.
+Beside these, the owner of the rewards is always authorized.
+See setAllowedClaimRecipients.
The percentage of voting power to be delegated to each delegatee, expressed in basis points (1/100 of one percent). Total of all _bips values must be lower than 10000.
Delegates a percentage of the caller's
+PDA's voting power to another address.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_to
+
address
+
The address of the recipient.
+
+
+
_bips
+
uint256
+
The percentage of voting power to be delegated expressed in basis points (1/100 of one percent). Not cumulative: Every call resets the delegation value. A value of 0 revokes delegation.
When using automatic claiming, all airdrops and FTSO rewards will be sent to the owner's account.
+Rewards accrued by the PDA will no longer be automatically claimed.
Registers the caller as an executor and sets its initial fee value.
+
If the executor was already registered, this method only updates the fee, which will take effect after
+feeValueUpdateOffset reward epochs have elapsed.
+
Executor must pay a fee in order to register. See registerExecutorFeeValueWei.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_feeValue
+
uint256
+
Desired fee, in wei. Must be between minFeeValueWei and maxFeeValueWei. 0 means no fee.
+
+
+
+
+
+
+
Returns
+
Type
+
Description
+
+
+
+
+
[0]
+
uint256
+
Reward epoch ID when the changes become effective.
Revokes all delegation from the caller's PDA
+to a given account at a given block.
+
Only affects the reads via votePowerOfAtCached() in the specified block.
+
This method should be used only to prevent rogue delegate voting in the current voting block.
+To stop delegating use delegate with percentage of 0 or undelegateAll.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_who
+
address
+
The account to revoke.
+
+
+
_blockNumber
+
uint256
+
Block number where the revoking will take place. Must be in the past.
Allows the caller to transfer ERC-20 tokens from their
+PDA to the owner account.
+
The main use case is to move ERC-20 tokes received by mistake (by an airdrop, for example) out of the PDA
+and into the main account, where they can be more easily managed.
+
Reverts if the target token is the WNat contract: use method withdraw for that.
Implement this function to receive a trigger from the FlareDaemon.
+The trigger method is called by the validator right at the end of block state transition.
+
+
+
+
Returns
+
Type
+
Description
+
+
+
+
+
[0]
+
bool
+
bool Whether the contract is still active after the call. Currently unused.
This function will be called after an error is caught in daemonize.
+It will switch the contract to a simpler fallback mode, which hopefully works when full mode doesn't.
+Not every contract needs to support fallback mode (FtsoManager does), so this method may be empty.
+Switching back to normal mode is left to the contract (typically a governed method call).
+This function may be called due to low-gas error, so it shouldn't use more than ~30.000 gas.
+
+
+
+
Returns
+
Type
+
Description
+
+
+
+
+
[0]
+
bool
+
True if switched to fallback mode, false if already in fallback mode or if fallback mode is not supported.
Not enough votes were received for this asset during a price epoch that has just ended.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
epochId
+
uint256
+
The ID of the epoch.
+
+
+
natTurnout
+
uint256
+
Total received vote power, as a percentage of the circulating supply in BIPS.
+
+
+
lowNatTurnoutThresholdBIPS
+
uint256
+
Minimum required vote power, as a percentage of the circulating supply in BIPS. The fact that this number is higher than natTurnout is what triggered this event.
+
+
+
timestamp
+
uint256
+
Timestamp of the block where the price epoch ended.
All necessary parameters have been set for an epoch and prices can start being revealed.
+Note that prices can already be submitted immediately after the previous price epoch submit end time is over.
Returns the random number for the previous price epoch, obtained from the random numbers
+provided by all data providers along with their data submissions.
Returns the random number used in a specific past epoch, obtained from the random numbers
+provided by all data providers along with their data submissions.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_epochId
+
uint256
+
ID of the queried epoch. Current epoch cannot be queried, and the previous epoch is constantly updated as data providers reveal their prices and random numbers. Only the last 50 epochs can be queried and there is no bounds checking for this parameter. Out-of-bounds queries return undefined values.
Emitted when the fallback mode of the FTSO manager changes its state.
+Fallback mode is a recovery mode, where only data from a trusted subset of FTSO
+data providers is used to calculate the final price.
+
The FTSO Manager enters the fallback mode when ALL FTSOs are in fallback mode.
Emitted when a price epoch ends, this is,
+after the reveal phase, when final prices are calculated.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
chosenFtso
+
address
+
Contract address of the FTSO asset that was randomly chosen to be the basis for reward calculation. On this price epoch, rewards will be calculated based on how close each data provider was to the median of all submitted prices FOR THIS FTSO.
Emitted when the requirement to provide good random numbers has changed.
+
As part of the FTSO protocol,
+data providers must submit a random number along with their price reveals.
+When good random numbers are enforced, all providers that submit a hash must then
+submit a reveal with a random number or they will be punished.
+This is a measure against random number manipulation.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
useGoodRandom
+
bool
+
Whether good random numbers are now enforced or not.
+
+
+
maxWaitForGoodRandomSeconds
+
uint256
+
Max number of seconds to wait for a good random number to be submitted.
Returns timing information for the current price epoch.
+All intervals are half-closed: end time is not included.
+All timestamps are in seconds since UNIX epoch.
+
See the FTSO page
+for information about the different submission phases.
Get array of all FTSO contracts for all supported asset indices.
+The index of FTSO in returned array does not necessarily correspond to the asset's index.
+Due to deletion, some indices might be unsupported.
+
Use getSupportedIndicesAndFtsos to retrieve pairs of correct indices and FTSOs,
+where possible "null" holes are readily apparent.
Emitted every price epoch, when rewards have been distributed to each contributing data provider.
+Note that rewards are not claimable until the reward epoch finishes.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
ftso
+
address
+
Address of the FTSO that generated the rewards.
+
+
+
epochId
+
uint256
+
ID of the reward epoch where the rewards were accrued.
+
+
+
addresses
+
address[]
+
Data provider addresses that have rewards to claim.
Emitted when rewards cannot be distributed during a reward epoch
+(for example, because the FTSO went into fallback mode) and they are accrued
+for later burning.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
epochId
+
uint256
+
ID of the reward epoch where the reward was accrued.
Allows claiming rewards simultaneously for a list of reward owners and all unclaimed epochs before the
+specified one.
+
This is meant as a convenience all-in-one reward claiming method to be used both by reward owners and
+registered executors.
+It performs a series of operations, besides claiming rewards:
+
+
+
If a reward owner has enabled its
+Personal Delegation Account, rewards are also
+claimed for the PDA and the total claimed amount is sent to that PDA.
+Otherwise, the claimed amount is sent to the reward owner's account.
+
+
+
Claimed amount is automatically wrapped through the WNat contract.
+
+
+
If the caller is a registered executor with a non-zero fee, the fee is paid to the executor for each claimed
+address.
+
+
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_rewardOwners
+
address[]
+
List of reward owners to claim for.
+
+
+
_rewardEpoch
+
uint256
+
Last reward epoch ID to claim for. All previous epochs with pending rewards will be claimed too.
Allows the caller to claim rewards for a reward owner.
+The caller does not have to be the owner of the rewards, but must be approved by the owner to claim on his
+behalf by using setClaimExecutors on the claimSetupManager.
+
This function is intended to be used to claim rewards in case of delegation by percentage.
+Reverts if msg.sender is delegating by amount.
+
Anybody can call this method, but rewards can only be sent to the reward owner, therefore no funds can be
+stolen. However, by limiting the authorized callers, the owner can control the timing of the calls.
+
When the reward owner is the caller, rewards can be sent to any recipient set by setAllowedClaimRecipients on
+the claimSetupManager.
+The reward owner's Personal Delegation Account
+is always an authorized recipient.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_rewardOwner
+
address
+
Address of the reward owner.
+
+
+
_recipient
+
address payable
+
Address to transfer claimed rewards to.
+
+
+
_rewardEpoch
+
uint256
+
Last reward epoch to claim for. All previous epochs with pending rewards will be claimed too.
+
+
+
_wrap
+
bool
+
Whether claimed rewards should be wrapped through the WNat contract before transferring them to the _recipient. This parameter is offered as a convenience.
Allows the caller to claim rewards for a reward owner from specific data providers.
+The caller does not have to be the owner of the rewards, but must be approved by the owner to claim on his
+behalf by using setClaimExecutors on the claimSetupManager.
+
This function is intended to be used to claim rewards in case of delegation by amount (explicit delegation).
+Reverts if msg.sender is delegating by percentage.
+
Anybody can call this method, but rewards can only be sent to the reward owner, therefore no funds can be
+stolen. However, by limiting the authorized callers, the owner can control the timing of the calls.
+
When the reward owner is the caller, rewards can be sent to any recipient set by setAllowedClaimRecipients on
+the claimSetupManager.
+The reward owner's Personal Delegation Account
+is always an authorized recipient.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_rewardOwner
+
address
+
Address of the reward owner.
+
+
+
_recipient
+
address payable
+
Address to transfer claimed rewards to.
+
+
+
_rewardEpochs
+
uint256[]
+
Array of reward epoch IDs to claim for.
+
+
+
_dataProviders
+
address[]
+
Array of addresses of the data providers to claim the reward from.
+
+
+
_wrap
+
bool
+
Whether claimed rewards should be wrapped through the WNat contract before transferring them to the _recipient. This parameter is offered as a convenience.
Reverts if msg.sender is delegating by amount.
+Claims for all unclaimed reward epochs to the 'max(_rewardEpochs)'.
+Retained for backward compatibility.
Allows the caller to claim rewards from specific data providers.
+This function is intended to be used to claim rewards in case of delegation by amount.
Returns the reward epoch range for which rewards can be claimed.
+Rewards outside this range are unclaimable, either because they have expired or because the reward epoch is
+still ongoing.
Returns the initial reward epoch ID for this reward manager contract.
+This corresponds to the oldest reward epoch with claimable rewards in the previous reward manager when this
+one took over.
+Set by governance through setInitialRewardData.
Gets the addresses of the accounts that are allowed to execute the timelocked governance calls,
+once the timelock period expires.
+Executors can be changed without a hard fork, via a normal governance call.
Gets the addresses of recipients allowed to receive rewards on behalf of an account.
+Beside these, the owner of the rewards is always authorized.
+See setAllowedClaimRecipients.
The percentage of voting power to be delegated to each delegatee, expressed in basis points (1/100 of one percent). Total of all _bips values must be lower than 10000.
Delegates a percentage of the caller's
+PDA's voting power to another address.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_to
+
address
+
The address of the recipient.
+
+
+
_bips
+
uint256
+
The percentage of voting power to be delegated expressed in basis points (1/100 of one percent). Not cumulative: Every call resets the delegation value. A value of 0 revokes delegation.
When using automatic claiming, all airdrops and FTSO rewards will be sent to the owner's account.
+Rewards accrued by the PDA will no longer be automatically claimed.
Gets the Personal Delegation Account (PDA) for
+a list of accounts for which an executor is claiming.
+Returns owner address instead if the PDA is not created yet or not enabled.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_executor
+
address
+
Executor to query.
+
+
+
_owners
+
address[]
+
Array of reward owners which must have set _executor as their executor.
+
+
+
+
+
+
+
Returns
+
Type
+
Description
+
+
+
+
+
_recipients
+
address[]
+
Addresses which will receive the claimed rewards. Can be the reward owners or their PDAs.
Registers the caller as an executor and sets its initial fee value.
+
If the executor was already registered, this method only updates the fee, which will take effect after
+feeValueUpdateOffset reward epochs have elapsed.
+
Executor must pay a fee in order to register. See registerExecutorFeeValueWei.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_feeValue
+
uint256
+
Desired fee, in wei. Must be between minFeeValueWei and maxFeeValueWei. 0 means no fee.
+
+
+
+
+
+
+
Returns
+
Type
+
Description
+
+
+
+
+
[0]
+
uint256
+
Reward epoch ID when the changes become effective.
Revokes all delegation from the caller's PDA
+to a given account at a given block.
+
Only affects the reads via votePowerOfAtCached() in the specified block.
+
This method should be used only to prevent rogue delegate voting in the current voting block.
+To stop delegating use delegate with percentage of 0 or undelegateAll.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_who
+
address
+
The account to revoke.
+
+
+
_blockNumber
+
uint256
+
Block number where the revoking will take place. Must be in the past.
Allows the caller to transfer ERC-20 tokens from their
+PDA to the owner account.
+
The main use case is to move ERC-20 tokes received by mistake (by an airdrop, for example) out of the PDA
+and into the main account, where they can be more easily managed.
+
Reverts if the target token is the WNat contract: use method withdraw for that.
Set the cleanup block number.
+Historic data for the blocks before cleanupBlockNumber can be erased.
+History before that block should never be used since it can be inconsistent.
+In particular, cleanup block number must be lower than the current vote power block.
Internal interface for each of the FTSO contracts that handles an asset.
+Read the FTSO documentation page
+for general information about the FTSO system.
Forces finalization of a price epoch, calculating the median price from trusted addresses only.
+
Used as a fallback method, for example, due to an unexpected error during normal epoch finalization or
+because the ftsoManager enabled the fallback mode.
Returns the random number for the previous price epoch, obtained from the random numbers
+provided by all data providers along with their data submissions.
Returns the random number used in a specific past epoch, obtained from the random numbers
+provided by all data providers along with their data submissions.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_epochId
+
uint256
+
ID of the queried epoch. Current epoch cannot be queried, and the previous epoch is constantly updated as data providers reveal their prices and random numbers. Only the last 50 epochs can be queried and there is no bounds checking for this parameter. Out-of-bounds queries return undefined values.
Emitted when the fallback mode of the FTSO manager changes its state.
+Fallback mode is a recovery mode, where only data from a trusted subset of FTSO
+data providers is used to calculate the final price.
+
The FTSO Manager enters the fallback mode when ALL FTSOs are in fallback mode.
Emitted when a price epoch ends, this is,
+after the reveal phase, when final prices are calculated.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
chosenFtso
+
address
+
Contract address of the FTSO asset that was randomly chosen to be the basis for reward calculation. On this price epoch, rewards will be calculated based on how close each data provider was to the median of all submitted prices FOR THIS FTSO.
Emitted when the requirement to provide good random numbers has changed.
+
As part of the FTSO protocol,
+data providers must submit a random number along with their price reveals.
+When good random numbers are enforced, all providers that submit a hash must then
+submit a reveal with a random number or they will be punished.
+This is a measure against random number manipulation.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
useGoodRandom
+
bool
+
Whether good random numbers are now enforced or not.
+
+
+
maxWaitForGoodRandomSeconds
+
uint256
+
Max number of seconds to wait for a good random number to be submitted.
Adds a list of FTSOs to the list of managed FTSOs, to support new price pairs.
+All FTSOs in a multi-asset FTSO must be managed by the same FTSO manager.
Implement this function to receive a trigger from the FlareDaemon.
+The trigger method is called by the validator right at the end of block state transition.
+
+
+
+
Returns
+
Type
+
Description
+
+
+
+
+
[0]
+
bool
+
bool Whether the contract is still active after the call. Currently unused.
Returns timing information for the current price epoch.
+All intervals are half-closed: end time is not included.
+All timestamps are in seconds since UNIX epoch.
+
See the FTSO page
+for information about the different submission phases.
Returns information regarding the currently unprocessed price epoch.
+This epoch is not necessarily the last one, in case the network halts for some
+time due to validator node problems, for example.
+
+
+
+
Returns
+
Type
+
Description
+
+
+
+
+
_lastUnprocessedPriceEpoch
+
uint256
+
ID of the price epoch that is currently waiting finalization.
+
+
+
_lastUnprocessedPriceEpochRevealEnds
+
uint256
+
When that price epoch can be finalized, in seconds since UNIX epoch.
+
+
+
_lastUnprocessedPriceEpochInitialized
+
bool
+
Whether this price epoch has been already initialized and therefore it must be finalized before the corresponding reward epoch can be finalized.
Replaces one FTSO with another with the same symbol.
+All FTSOs in a multi-asset FTSO must be managed by the same FTSO manager.
+Deactivates the old FTSO.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_ftsoToAdd
+
contract IIFtso
+
FTSO contract address to add. An existing FTSO with the same symbol will be removed.
+
+
+
copyCurrentPrice
+
bool
+
When true, initializes the new FTSO with the current price of the previous FTSO.
+
+
+
copyAssetOrAssetFtsos
+
bool
+
When true, initializes the new FTSO with the current asset or asset FTSOs of the previous FTSO.
Replaces a list of FTSOs with other FTSOs with the same symbol.
+All FTSOs in a multi-asset FTSO must be managed by the same FTSO manager.
+Deactivates the old FTSOs.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_ftsosToAdd
+
contract IIFtso[]
+
Array of FTSO contract addresses to add. Every existing FTSO with the same symbols will be removed.
+
+
+
copyCurrentPrice
+
bool
+
When true, initializes the new FTSOs with the current price of the previous FTSOs.
+
+
+
copyAssetOrAssetFtsos
+
bool
+
When true, initializes the new FTSOs with the current asset or asset FTSOs of the previous FTSOs.
This function will be called after an error is caught in daemonize.
+It will switch the contract to a simpler fallback mode, which hopefully works when full mode doesn't.
+Not every contract needs to support fallback mode (FtsoManager does), so this method may be empty.
+Switching back to normal mode is left to the contract (typically a governed method call).
+This function may be called due to low-gas error, so it shouldn't use more than ~30.000 gas.
+
+
+
+
Returns
+
Type
+
Description
+
+
+
+
+
[0]
+
bool
+
True if switched to fallback mode, false if already in fallback mode or if fallback mode is not supported.
Get array of all FTSO contracts for all supported asset indices.
+The index of FTSO in returned array does not necessarily correspond to the asset's index.
+Due to deletion, some indices might be unsupported.
+
Use getSupportedIndicesAndFtsos to retrieve pairs of correct indices and FTSOs,
+where possible "null" holes are readily apparent.
Removes the FTSO and keeps part of the history.
+Reverts if the provided address is not supported.
+
From now on, the index this asset was using is "reserved" and cannot be used again.
+It will not be returned in any list of currently supported assets.
Emitted every price epoch, when rewards have been distributed to each contributing data provider.
+Note that rewards are not claimable until the reward epoch finishes.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
ftso
+
address
+
Address of the FTSO that generated the rewards.
+
+
+
epochId
+
uint256
+
ID of the reward epoch where the rewards were accrued.
+
+
+
addresses
+
address[]
+
Data provider addresses that have rewards to claim.
Emitted when rewards cannot be distributed during a reward epoch
+(for example, because the FTSO went into fallback mode) and they are accrued
+for later burning.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
epochId
+
uint256
+
ID of the reward epoch where the reward was accrued.
Accrue unearned rewards for a given price epoch.
+Typically done when the FTSO is in fallback mode or because of insufficient vote power.
+Simply accrue them so they will not be distributed and will be burned later.
+
The amount of rewards that will be burned is calculated in the same way as in distributeRewards.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
epochId
+
uint256
+
Price epoch ID.
+
+
+
priceEpochDurationSeconds
+
uint256
+
Duration of price epochs (180s).
+
+
+
priceEpochEndTime
+
uint256
+
Timestamp of the price epoch end time (end of submit period), in seconds since UNIX epoch.
Allows claiming rewards simultaneously for a list of reward owners and all unclaimed epochs before the
+specified one.
+
This is meant as a convenience all-in-one reward claiming method to be used both by reward owners and
+registered executors.
+It performs a series of operations, besides claiming rewards:
+
+
+
If a reward owner has enabled its
+Personal Delegation Account, rewards are also
+claimed for the PDA and the total claimed amount is sent to that PDA.
+Otherwise, the claimed amount is sent to the reward owner's account.
+
+
+
Claimed amount is automatically wrapped through the WNat contract.
+
+
+
If the caller is a registered executor with a non-zero fee, the fee is paid to the executor for each claimed
+address.
+
+
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_rewardOwners
+
address[]
+
List of reward owners to claim for.
+
+
+
_rewardEpoch
+
uint256
+
Last reward epoch ID to claim for. All previous epochs with pending rewards will be claimed too.
Allows the caller to claim rewards for a reward owner.
+The caller does not have to be the owner of the rewards, but must be approved by the owner to claim on his
+behalf by using setClaimExecutors on the claimSetupManager.
+
This function is intended to be used to claim rewards in case of delegation by percentage.
+Reverts if msg.sender is delegating by amount.
+
Anybody can call this method, but rewards can only be sent to the reward owner, therefore no funds can be
+stolen. However, by limiting the authorized callers, the owner can control the timing of the calls.
+
When the reward owner is the caller, rewards can be sent to any recipient set by setAllowedClaimRecipients on
+the claimSetupManager.
+The reward owner's Personal Delegation Account
+is always an authorized recipient.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_rewardOwner
+
address
+
Address of the reward owner.
+
+
+
_recipient
+
address payable
+
Address to transfer claimed rewards to.
+
+
+
_rewardEpoch
+
uint256
+
Last reward epoch to claim for. All previous epochs with pending rewards will be claimed too.
+
+
+
_wrap
+
bool
+
Whether claimed rewards should be wrapped through the WNat contract before transferring them to the _recipient. This parameter is offered as a convenience.
Allows the caller to claim rewards for a reward owner from specific data providers.
+The caller does not have to be the owner of the rewards, but must be approved by the owner to claim on his
+behalf by using setClaimExecutors on the claimSetupManager.
+
This function is intended to be used to claim rewards in case of delegation by amount (explicit delegation).
+Reverts if msg.sender is delegating by percentage.
+
Anybody can call this method, but rewards can only be sent to the reward owner, therefore no funds can be
+stolen. However, by limiting the authorized callers, the owner can control the timing of the calls.
+
When the reward owner is the caller, rewards can be sent to any recipient set by setAllowedClaimRecipients on
+the claimSetupManager.
+The reward owner's Personal Delegation Account
+is always an authorized recipient.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_rewardOwner
+
address
+
Address of the reward owner.
+
+
+
_recipient
+
address payable
+
Address to transfer claimed rewards to.
+
+
+
_rewardEpochs
+
uint256[]
+
Array of reward epoch IDs to claim for.
+
+
+
_dataProviders
+
address[]
+
Array of addresses of the data providers to claim the reward from.
+
+
+
_wrap
+
bool
+
Whether claimed rewards should be wrapped through the WNat contract before transferring them to the _recipient. This parameter is offered as a convenience.
Reverts if msg.sender is delegating by amount.
+Claims for all unclaimed reward epochs to the 'max(_rewardEpochs)'.
+Retained for backward compatibility.
Allows the caller to claim rewards from specific data providers.
+This function is intended to be used to claim rewards in case of delegation by amount.
Collects funds from expired reward epoch and calculates totals.
+
Triggered by ftsoManager on finalization of a reward epoch.
+Operation is irreversible: when some reward epoch is closed according to current
+settings, it cannot be reopened even if new parameters would
+allow it, because nextRewardEpochToExpire in ftsoManager never decreases.
Distributes price epoch rewards to data provider accounts, according to input parameters.
+Must be called with totalWeight > 0 and addresses.length > 0.
+
The amount of rewards for a given price epoch ID are calculated in FtsoRewardManager from
+priceEpochDurationSeconds, priceEpochEndTime and inflation authorization data
+(see _getTotalPriceEpochRewardWei in FtsoRewardManager.
+Then each data provider address is given a portion of this amount according to corresponding weight
+and total sum of weights.
+
Parameters epochId and ftso are only needed so they can be passed onto the emitted event.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
addresses
+
address[]
+
Data provider addresses to reward.
+
+
+
weights
+
uint256[]
+
Weights corresponding to rewarded addresses.
+
+
+
totalWeight
+
uint256
+
Sum of all weights.
+
+
+
epochId
+
uint256
+
Price epoch ID.
+
+
+
ftso
+
address
+
Randomly chosen FTSO contract used to calculate the weights.
+
+
+
priceEpochDurationSeconds
+
uint256
+
Duration of price epochs (180s).
+
+
+
currentRewardEpoch
+
uint256
+
ID of the current reward epoch. Rewards for the price epoch are added to this reward epoch.
+
+
+
priceEpochEndTime
+
uint256
+
Timestamp of the price epoch end time (end of submit period), in seconds since UNIX epoch.
Returns the reward epoch range for which rewards can be claimed.
+Rewards outside this range are unclaimable, either because they have expired or because the reward epoch is
+still ongoing.
Returns the initial reward epoch ID for this reward manager contract.
+This corresponds to the oldest reward epoch with claimable rewards in the previous reward manager when this
+one took over.
+Set by governance through setInitialRewardData.
Total amount of funds ever locked in the token pool (wei). _lockedFundsWei - _totalClaimedWei is the amount currently locked and outside the circulating supply.
Returns information on unclaimed rewards for a given data provider and epoch.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_rewardEpoch
+
uint256
+
Queried reward epoch ID.
+
+
+
_dataProvider
+
address
+
Address of the queried data provider.
+
+
+
+
+
+
+
Returns
+
Type
+
Description
+
+
+
+
+
_amount
+
uint256
+
Amount available to be claimed, in wei.
+
+
+
_weight
+
uint256
+
Portion of total vote power used in this reward epoch that has not yet claimed its reward, in BIPS. It decreases to 0 when all data providers have claimed their rewards.
Set the cleanup block number.
+Historic data for the blocks before cleanupBlockNumber can be erased.
+History before that block should never be used since it can be inconsistent.
+In particular, cleanup block number must be lower than the current vote power block.
Returns the random number for the previous epoch, obtained from the random numbers
+provided by all data providers along with their data submissions.
+Note that the random number for the previous epoch keeps updating as new submissions are revealed.
+
+
+
+
Returns
+
Type
+
Description
+
+
+
+
+
[0]
+
uint256
+
Random number calculated from all data provider's submissions.
Returns the random number used in a specific past epoch, obtained from the random numbers
+provided by all data providers along with their data submissions.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_epochId
+
uint256
+
ID of the queried epoch. Current epoch cannot be queried, and the previous epoch is constantly updated as data providers reveal their prices and random numbers. Note that only the last 50 epochs can be queried and there is no bounds checking for this parameter. Out-of-bounds queries return undefined values.
Reveals submitted prices during the epoch reveal period.
+The hash of FTSO indices, prices, random number, and voter address must be equal
+to the hash previously submitted with submitHash.
+Emits a PricesRevealed event.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_epochId
+
uint256
+
ID of the epoch to which the price hashes are submitted.
Submits a hash for the current epoch. Can only be called by FTSO data providers
+whitelisted through the VoterWhitelisted contract.
+Emits the HashSubmitted event.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_epochId
+
uint256
+
ID of the target epoch to which the hash is submitted.
+
+
+
_hash
+
bytes32
+
A hash of the FTSO indices, prices, random number, and voter address.
Total amount of funds ever locked in the token pool (wei). _lockedFundsWei - _totalClaimedWei is the amount currently locked and outside the circulating supply.
Delegate_bips percentage of voting power from a delegator address to a delegatee address.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_from
+
address
+
The address of the delegator.
+
+
+
_to
+
address
+
The address of the delegatee.
+
+
+
_balance
+
uint256
+
The delegator's current balance
+
+
+
_bips
+
uint256
+
The percentage of voting power to be delegated expressed in basis points (1/100 of one percent). Not cumulative: every call resets the delegation value (and a value of 0 revokes delegation).
Get the delegation mode of an address. This mode determines whether vote power is
+allocated by percentage or by explicit value and cannot be changed once set with
+delegate or delegateExplicit.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_who
+
address
+
The address being queried.
+
+
+
+
+
+
+
Returns
+
Type
+
Description
+
+
+
+
+
[0]
+
uint256
+
Delegation mode (NOTSET=0, PERCENTAGE=1, AMOUNT=2). See Delegatable.DelegationMode.
Return true if this IIVPContract is configured to be used as a replacement for other contract.
+It means that vote powers are not necessarily correct at the initialization, therefore
+every method that reads vote power must check whether it is initialized for that address and block.
The VPToken (or some other contract) that owns this VPContract.
+All state changing methods may be called only from this address.
+This is because original msg.sender is typically sent in a parameter
+and we must make sure that it cannot be faked by directly calling
+IIVPContract methods.
+Owner token is also used in case of replacement to recover vote powers from balances.
Revoke all vote power delegation from a delegator address to a delegatee address at a given block.
+Only affects the reads via votePowerOfAtCached in the block _blockNumber.
+This method should be used only to prevent rogue delegate voting in the current voting block.
+To stop delegating use delegate or delegateExplicit with value of 0,
+or undelegateAll/ undelegateAllExplicit.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_from
+
address
+
The address of the delegator.
+
+
+
_to
+
address
+
Address of the delegatee.
+
+
+
_balance
+
uint256
+
The delegator's current balance.
+
+
+
_blockNumber
+
uint256
+
The block number at which to revoke delegation. Must be in the past.
Set the cleanup block number.
+Historic data for the blocks before cleanupBlockNumber can be erased.
+History before that block should never be used since it can be inconsistent.
+In particular, cleanup block number must be lower than the current vote power block.
Undelegate all explicit vote power by amount for a delegator address.
+Can only be used with explicit delegation.
+Does not reset delegation mode back to NOTSET.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_from
+
address
+
The address of the delegator.
+
+
+
_delegateAddresses
+
address[]
+
Explicit delegation does not store delegatees' addresses, so the caller must supply them.
+
+
+
+
+
+
+
Returns
+
Type
+
Description
+
+
+
+
+
[0]
+
uint256
+
The amount still delegated (in case the list of delegates was incomplete).
Update vote powers when tokens are transferred.
+Also update delegated vote powers for percentage delegation
+and check for enough funds for explicit delegations.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_from
+
address
+
Source account of the transfer.
+
+
+
_to
+
address
+
Destination account of the transfer.
+
+
+
_fromBalance
+
uint256
+
Balance of the source account before the transfer.
+
+
+
_toBalance
+
uint256
+
Balance of the destination account before the transfer.
Sets amount as the allowance of spender over the caller's tokens.
+
Returns a boolean value indicating whether the operation succeeded.
+
IMPORTANT: Beware that changing an allowance with this method brings the risk
+that someone may use both the old and the new allowance by unfortunate
+transaction ordering. One possible solution to mitigate this race
+condition is to first reduce the spender's allowance to 0 and set the
+desired value afterwards:
+https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
Undelegate all percentage delegations from the sender and then delegate corresponding
+ _bips percentage of voting power from the sender to each member of the _delegatees array.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_delegatees
+
address[]
+
The addresses of the new recipients.
+
+
+
_bips
+
uint256[]
+
The percentages of voting power to be delegated expressed in basis points (1/100 of one percent). The sum of all _bips values must be at most 10000 (100%).
Returns the number of decimals used to get its user representation.
+For example, if decimals equals 2, a balance of 505 tokens should
+be displayed to a user as 5.05 (505 / 102).
+
Tokens usually opt for a value of 18, imitating the relationship between
+Ether and wei. This is the default value returned by this function, unless
+it's overridden.
+
NOTE: This information is only used for display purposes: it in
+no way affects any of the arithmetic of the contract, including
+balanceOf and transfer.
Delegate voting power to account _to from msg.sender, by percentage.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_to
+
address
+
The address of the recipient.
+
+
+
_bips
+
uint256
+
The percentage of voting power to be delegated expressed in basis points (1/100 of one percent). Not cumulative: every call resets the delegation value (and a value of 0 revokes all previous delegations).
Explicitly delegate_amount voting power to account _to from msg.sender.
+Compare with delegate which delegates by percentage.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_to
+
address
+
The address of the recipient.
+
+
+
_amount
+
uint256
+
An explicit vote power amount to be delegated. Not cumulative: every call resets the delegation value (and a value of 0 revokes all previous delegations).
Get the list of addresses to which _who is delegating, and their percentages.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_who
+
address
+
The address to query.
+
+
+
+
+
+
+
Returns
+
Type
+
Description
+
+
+
+
+
_delegateAddresses
+
address[]
+
Positional array of addresses being delegated to.
+
+
+
_bips
+
uint256[]
+
Positional array of delegation percents specified in basis points (1/100 of 1 percent). Each one matches the address in the same position in the _delegateAddresses array.
Get the list of addresses to which _who is delegating, and their percentages, at the given block.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_who
+
address
+
The address to query.
+
+
+
_blockNumber
+
uint256
+
The block number to query.
+
+
+
+
+
+
+
Returns
+
Type
+
Description
+
+
+
+
+
_delegateAddresses
+
address[]
+
Positional array of addresses being delegated to.
+
+
+
_bips
+
uint256[]
+
Positional array of delegation percents specified in basis points (1/100 of 1 percent). Each one matches the address in the same position in the _delegateAddresses array.
Get the delegation mode for account '_who'. This mode determines whether vote power is
+allocated by percentage or by explicit amount. Once the delegation mode is set,
+it can never be changed, even if all delegations are removed.
Returns VPContract event interface used for read-only operations (view methods).
+The only non-view method that might be called on it is revokeDelegationAt.
Do not call any methods on VPContract directly.
+State changing methods are forbidden from direct calls.
+All methods are exposed via VPToken.
+This is the reason that this method returns IVPContractEvents.
+Use it only for listening to events and revoking.
Revoke all delegation from sender to _who at given block.
+Only affects the reads via votePowerOfAtCached() in the block _blockNumber.
+Block _blockNumber must be in the past.
+This method should be used only to prevent rogue delegate voting in the current voting block.
+To stop delegating use delegate / delegateExplicit with value of 0 or undelegateAll / undelegateAllExplicit.
Set the cleanup block number.
+Historic data for the blocks before cleanupBlockNumber can be erased.
+History before that block should never be used since it can be inconsistent.
+In particular, cleanup block number must be lower than the current vote power block.
Get the total vote power at block _blockNumber using cache.
+ It tries to read the cached value and if it is not found, reads the actual value and stores it in the cache.
+ Can only be used if _blockNumber is in the past, otherwise reverts.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_blockNumber
+
uint256
+
The block number to query.
+
+
+
+
+
+
+
Returns
+
Type
+
Description
+
+
+
+
+
[0]
+
uint256
+
The total vote power at the queried block (sum of all accounts' vote powers).
Undelegate all voting power of msg.sender. This effectively revokes all previous delegations.
+Can only be used with percentage delegation.
+Does not reset delegation mode back to NOT SET.
Undelegate all explicit vote power by amount of msg.sender.
+Can only be used with explicit delegation.
+Does not reset delegation mode back to NOT SET.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_delegateAddresses
+
address[]
+
Explicit delegation does not store delegatees' addresses, so the caller must supply them.
+
+
+
+
+
+
+
Returns
+
Type
+
Description
+
+
+
+
+
[0]
+
uint256
+
The amount still delegated (in case the list of delegates was incomplete).
Get the vote power of _owner at block _blockNumber using cache.
+ It tries to read the cached value and if it is not found, reads the actual value and stores it in the cache.
+ Can only be used if _blockNumber is in the past, otherwise reverts.
Returns VPContract event interface used for state-changing operations (non-view methods).
+The only non-view method that might be called on it is revokeDelegationAt.
+
writeVotePowerContract is almost always equal to readVotePowerContract,
+except during upgrade from one VPContract to a new version (which should happen
+rarely or never and will be announced beforehand).
+In the case of an upgrade, writeVotePowerContract is replaced first to establish delegations.
+After some period (e.g., after a reward epoch ends), readVotePowerContract is set equal to it.
+
Do not call any methods on VPContract directly.
+State changing methods are forbidden from direct calls.
+All are exposed via VPToken.
+This is the reason that this method returns IVPContractEvents
+Use it only for listening to events, delegating, and revoking.
In case of providing bad prices (e.g. collusion), the voter can be chilled for a few reward epochs.
+A voter can whitelist again from a returned reward epoch onwards.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_voter
+
address
+
Address of the queried data provider.
+
+
+
+
+
+
+
Returns
+
Type
+
Description
+
+
+
+
+
[0]
+
uint256
+
uint256 ID of the epoch where the data provider can start submitting prices again.
Requests whitelisting an account to act as a data provider for a specific FTSO.
+Reverts if the vote power of the account is too low.
+May be called by any address, including the voter itself.
Receive newly minted native tokens from the FlareDaemon.
+
Assume that the received amount will be >= last topup requested across all services.
+If there is not enough balance sent to cover the topup request, expect the library method to revert.
+Also assume that any received balance greater than the calculated topup request
+came from self-destructor sending a balance to this contract.
Returns the random number for the previous epoch, obtained from the random numbers
+provided by all data providers along with their data submissions.
+Note that the random number for the previous epoch keeps updating as new submissions are revealed.
+
+
+
+
Returns
+
Type
+
Description
+
+
+
+
+
[0]
+
uint256
+
Random number calculated from all data provider's submissions.
Returns the random number used in a specific past epoch, obtained from the random numbers
+provided by all data providers along with their data submissions.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_epochId
+
uint256
+
ID of the queried epoch. Current epoch cannot be queried, and the previous epoch is constantly updated as data providers reveal their prices and random numbers. Note that only the last 50 epochs can be queried and there is no bounds checking for this parameter. Out-of-bounds queries return undefined values.
Reveals submitted prices during the epoch reveal period.
+The hash of FTSO indices, prices, random number, and voter address must be equal
+to the hash previously submitted with submitHash.
+Emits a PricesRevealed event.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_epochId
+
uint256
+
ID of the epoch to which the price hashes are submitted.
Submits a hash for the current epoch. Can only be called by FTSO data providers
+whitelisted through the VoterWhitelisted contract.
+Emits the HashSubmitted event.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_epochId
+
uint256
+
ID of the target epoch to which the hash is submitted.
+
+
+
_hash
+
bytes32
+
A hash of the FTSO indices, prices, random number, and voter address.
Sets amount as the allowance of spender over the caller's tokens.
+
Returns a boolean value indicating whether the operation succeeded.
+
IMPORTANT: Beware that changing an allowance with this method brings the risk
+that someone may use both the old and the new allowance by unfortunate
+transaction ordering. One possible solution to mitigate this race
+condition is to first reduce the spender's allowance to 0 and set the
+desired value afterwards:
+https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
Undelegate all percentage delegations from the sender and then delegate corresponding
+ _bips percentage of voting power from the sender to each member of the _delegatees array.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_delegatees
+
address[]
+
The addresses of the new recipients.
+
+
+
_bips
+
uint256[]
+
The percentages of voting power to be delegated expressed in basis points (1/100 of one percent). The sum of all _bips values must be at most 10000 (100%).
Returns the number of decimals used to get its user representation.
+For example, if decimals equals 2, a balance of 505 tokens should
+be displayed to a user as 5.05 (505 / 102).
+
Tokens usually opt for a value of 18, imitating the relationship between
+Ether and wei. This is the default value returned by this function, unless
+it's overridden.
+
NOTE: This information is only used for display purposes: it in
+no way affects any of the arithmetic of the contract, including
+balanceOf and transfer.
Delegate voting power to account _to from msg.sender, by percentage.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_to
+
address
+
The address of the recipient.
+
+
+
_bips
+
uint256
+
The percentage of voting power to be delegated expressed in basis points (1/100 of one percent). Not cumulative: every call resets the delegation value (and a value of 0 revokes all previous delegations).
Explicitly delegate_amount voting power to account _to from msg.sender.
+Compare with delegate which delegates by percentage.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_to
+
address
+
The address of the recipient.
+
+
+
_amount
+
uint256
+
An explicit vote power amount to be delegated. Not cumulative: every call resets the delegation value (and a value of 0 revokes all previous delegations).
Get the list of addresses to which _who is delegating, and their percentages.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_who
+
address
+
The address to query.
+
+
+
+
+
+
+
Returns
+
Type
+
Description
+
+
+
+
+
_delegateAddresses
+
address[]
+
Positional array of addresses being delegated to.
+
+
+
_bips
+
uint256[]
+
Positional array of delegation percents specified in basis points (1/100 of 1 percent). Each one matches the address in the same position in the _delegateAddresses array.
Get the list of addresses to which _who is delegating, and their percentages, at the given block.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_who
+
address
+
The address to query.
+
+
+
_blockNumber
+
uint256
+
The block number to query.
+
+
+
+
+
+
+
Returns
+
Type
+
Description
+
+
+
+
+
_delegateAddresses
+
address[]
+
Positional array of addresses being delegated to.
+
+
+
_bips
+
uint256[]
+
Positional array of delegation percents specified in basis points (1/100 of 1 percent). Each one matches the address in the same position in the _delegateAddresses array.
Get the delegation mode for account '_who'. This mode determines whether vote power is
+allocated by percentage or by explicit amount. Once the delegation mode is set,
+it can never be changed, even if all delegations are removed.
Returns VPContract event interface used for read-only operations (view methods).
+The only non-view method that might be called on it is revokeDelegationAt.
Do not call any methods on VPContract directly.
+State changing methods are forbidden from direct calls.
+All methods are exposed via VPToken.
+This is the reason that this method returns IVPContractEvents.
+Use it only for listening to events and revoking.
Revoke all delegation from sender to _who at given block.
+Only affects the reads via votePowerOfAtCached() in the block _blockNumber.
+Block _blockNumber must be in the past.
+This method should be used only to prevent rogue delegate voting in the current voting block.
+To stop delegating use delegate / delegateExplicit with value of 0 or undelegateAll / undelegateAllExplicit.
Undelegate all voting power of msg.sender. This effectively revokes all previous delegations.
+Can only be used with percentage delegation.
+Does not reset delegation mode back to NOT SET.
Undelegate all explicit vote power by amount of msg.sender.
+Can only be used with explicit delegation.
+Does not reset delegation mode back to NOT SET.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_delegateAddresses
+
address[]
+
Explicit delegation does not store delegatees' addresses, so the caller must supply them.
+
+
+
+
+
+
+
Returns
+
Type
+
Description
+
+
+
+
+
[0]
+
uint256
+
The amount still delegated (in case the list of delegates was incomplete).
Returns VPContract event interface used for state-changing operations (non-view methods).
+The only non-view method that might be called on it is revokeDelegationAt.
+
writeVotePowerContract is almost always equal to readVotePowerContract,
+except during upgrade from one VPContract to a new version (which should happen
+rarely or never and will be announced beforehand).
+In the case of an upgrade, writeVotePowerContract is replaced first to establish delegations.
+After some period (e.g., after a reward epoch ends), readVotePowerContract is set equal to it.
+
Do not call any methods on VPContract directly.
+State changing methods are forbidden from direct calls.
+All are exposed via VPToken.
+This is the reason that this method returns IVPContractEvents
+Use it only for listening to events, delegating, and revoking.
In case of providing bad prices (e.g. collusion), the voter can be chilled for a few reward epochs.
+A voter can whitelist again from a returned reward epoch onwards.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_voter
+
address
+
Address of the queried data provider.
+
+
+
+
+
+
+
Returns
+
Type
+
Description
+
+
+
+
+
[0]
+
uint256
+
uint256 ID of the epoch where the data provider can start submitting prices again.
Requests whitelisting an account to act as a data provider for a specific FTSO.
+Reverts if the vote power of the account is too low.
+May be called by any address, including the voter itself.
This contract converts native tokens into WNAT (wrapped native) tokens and vice versa.
+WNAT tokens are a one-to-one ERC20
+representation of native tokens, which are minted and burned as needed by this contract.
+
The wrapped versions of the native FLR and SGB tokens are called WFLR and WSGB respectively.
Deposits native tokens and mints the same amount of WNAT tokens,
+which are added to the msg.sender's balance.
+This operation is commonly known as "wrapping".
Deposits native tokens and mints the same amount of WNAT tokens,
+which are added to _recipient's balance.
+This operation is commonly known as "wrapping".
+
This is equivalent to using deposit followed by transfer.
Burns _amount of WNAT tokens from msg.sender's WNAT balance and
+transfers the same amount of native tokens to msg.sender.
+This operation is commonly known as "unwrapping".
+
Reverts if _amount is higher than msg.sender's WNAT balance.
Burns _amount of WNAT tokens from _owner's WNAT balance and
+transfers the same amount of native tokens to msg.sender.
+This operation is commonly known as "unwrapping".
+
msg.sender must have been authorized to withdraw from _owner's account
+through ERC-20's approve mechanism.
+
Reverts if _amount is higher than _owners's WNAT balance or than
+msg.sender's allowance over _owner's tokens.
Implement this function to receive a trigger from the FlareDaemon.
+The trigger method is called by the validator right at the end of block state transition.
+
+
+
+
Returns
+
Type
+
Description
+
+
+
+
+
[0]
+
bool
+
bool Whether the contract is still active after the call. Currently unused.
Returns next expected inflation topup time stamp which is also inflation authorization time.
+The returned time from this API is actually the time of the block in which the topup is requested.
+The Actual topup will take place in the next block.
+Expected diff is up to a few seconds (max is less then a minute).
Receive newly minted native tokens from the FlareDaemon.
+
Assume that the received amount will be >= last topup requested across all services.
+If there is not enough balance sent to cover the topup request, expect the library method to revert.
+Also assume that any received balance greater than the calculated topup request
+came from self-destructor sending a balance to this contract.
Topup factor, if _topupType == FACTOROFDAILYAUTHORIZED, must be greater than 100.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_inflationReceiver
+
contract IIInflationReceiver
+
The reward service to receive the inflation funds for distribution.
+
+
+
_topupType
+
enum TopupType
+
The type to signal how the topup amounts are to be calculated. FACTOROFDAILYAUTHORIZED = Use a factor of last daily authorized to set a target balance for a reward service to maintain as a reserve for claiming. ALLAUTHORIZED = Mint enough native tokens to topup reward service contract to hold all authorized but unrequested rewards.
+
+
+
_topupFactorX100
+
uint256
+
If _topupType == FACTOROFDAILYAUTHORIZED, then this factor (times 100) is multiplied by last daily authorized inflation to obtain the maximum balance that a reward service can hold at any given time. If it holds less, then this max amount is used to compute the mint request topup required to bring the reward service contract native token balance up to that amount.
This function will be called after an error is caught in daemonize.
+It will switch the contract to a simpler fallback mode, which hopefully works when full mode doesn't.
+Not every contract needs to support fallback mode (FtsoManager does), so this method may be empty.
+Switching back to normal mode is left to the contract (typically a governed method call).
+This function may be called due to low-gas error, so it shouldn't use more than ~30.000 gas.
+
+
+
+
Returns
+
Type
+
Description
+
+
+
+
+
[0]
+
bool
+
True if switched to fallback mode, false if already in fallback mode or if fallback mode is not supported.
It then forwards the submissions to the appropriate FTSO contract,
+allowing data providers to perform all required operations in a single transaction
+per price epoch.
This constructor should contain no code as this contract is pre-loaded into the genesis block.
+ The super constructors are called for testing convenience.
Returns the random number for the previous epoch, obtained from the random numbers
+provided by all data providers along with their data submissions.
+Note that the random number for the previous epoch keeps updating as new submissions are revealed.
+
It never reverts.
+
+
+
+
Returns
+
Type
+
Description
+
+
+
+
+
[0]
+
uint256
+
Random number calculated from all data provider's submissions.
Returns the random number used in a specific past epoch, obtained from the random numbers
+provided by all data providers along with their data submissions.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_epochId
+
uint256
+
ID of the queried epoch. Current epoch cannot be queried, and the previous epoch is constantly updated as data providers reveal their prices and random numbers. Note that only the last 50 epochs can be queried and there is no bounds checking for this parameter. Out-of-bounds queries return undefined values.
Reveals submitted prices during the epoch reveal period.
+The hash of FTSO indices, prices, random number, and voter address must be equal
+to the hash previously submitted with submitHash.
+Emits a PricesRevealed event.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_epochId
+
uint256
+
ID of the epoch to which the price hashes are submitted.
Set the trusted addresses that are always allowed to submit and reveal.
+Trusted addresses are used, for example, in fallback mode.
+Only FTSO Manager can call this method.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_trustedAddresses
+
address[]
+
Array of FTSO data provider addresses (voters). The previous list of trusted addresses is discarded.
Submits a hash for the current epoch. Can only be called by FTSO data providers
+whitelisted through the VoterWhitelisted contract.
+Emits the HashSubmitted event.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_epochId
+
uint256
+
ID of the target epoch to which the hash is submitted.
+
+
+
_hash
+
bytes32
+
A hash of the FTSO indices, prices, random number, and voter address.
Delegate_bips percentage of voting power from a delegator address to a delegatee address.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_from
+
address
+
The address of the delegator.
+
+
+
_to
+
address
+
The address of the delegatee.
+
+
+
_balance
+
uint256
+
The delegator's current balance
+
+
+
_bips
+
uint256
+
The percentage of voting power to be delegated expressed in basis points (1/100 of one percent). Not cumulative: every call resets the delegation value (and a value of 0 revokes delegation).
Get the delegation mode of an address. This mode determines whether vote power is
+allocated by percentage or by explicit value and cannot be changed once set with
+delegate or delegateExplicit.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_who
+
address
+
The address being queried.
+
+
+
+
+
+
+
Returns
+
Type
+
Description
+
+
+
+
+
[0]
+
uint256
+
Delegation mode (NOTSET=0, PERCENTAGE=1, AMOUNT=2). See Delegatable.DelegationMode.
Delete explicit delegation checkpoints that expired (i.e. are before cleanupBlockNumber).
+Method can only be called from the cleanerContract (which may be a proxy to external cleaners).
Return true if this IIVPContract is configured to be used as a replacement for other contract.
+It means that vote powers are not necessarily correct at the initialization, therefore
+every method that reads vote power must check whether it is initialized for that address and block.
The VPToken (or some other contract) that owns this VPContract.
+All state changing methods may be called only from this address.
+This is because original msg.sender is typically sent in a parameter
+and we must make sure that it cannot be faked by directly calling
+IIVPContract methods.
+Owner token is also used in case of replacement to recover vote powers from balances.
Delete percentage delegation checkpoints that expired (i.e. are before cleanupBlockNumber).
+Method can only be called from the cleanerContract (which may be a proxy to external cleaners).
Delete revocation entry that expired (i.e. is before cleanupBlockNumber).
+Method can only be called from the cleanerContract (which may be a proxy to external cleaners).
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_from
+
address
+
Delegator address.
+
+
+
_to
+
address
+
Delegatee address.
+
+
+
_blockNumber
+
uint256
+
Block number for which total supply value was cached.
+
+
+
+
+
+
+
Returns
+
Type
+
Description
+
+
+
+
+
[0]
+
uint256
+
Number of revocation entries deleted (always 0 or 1).
Revoke all vote power delegation from a delegator address to a delegatee address at a given block.
+Only affects the reads via votePowerOfAtCached in the block _blockNumber.
+This method should be used only to prevent rogue delegate voting in the current voting block.
+To stop delegating use delegate or delegateExplicit with value of 0,
+or undelegateAll/ undelegateAllExplicit.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_from
+
address
+
The address of the delegator.
+
+
+
_to
+
address
+
Address of the delegatee.
+
+
+
_balance
+
uint256
+
The delegator's current balance.
+
+
+
_blockNumber
+
uint256
+
The block number at which to revoke delegation. Must be in the past.
Set the cleanup block number.
+Historic data for the blocks before cleanupBlockNumber can be erased.
+History before that block should never be used since it can be inconsistent.
+In particular, cleanup block number must be lower than the current vote power block.
Undelegate all explicit vote power by amount for a delegator address.
+Can only be used with explicit delegation.
+Does not reset delegation mode back to NOTSET.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_from
+
address
+
The address of the delegator.
+
+
+
_delegateAddresses
+
address[]
+
Explicit delegation does not store delegatees' addresses, so the caller must supply them.
+
+
+
+
+
+
+
Returns
+
Type
+
Description
+
+
+
+
+
[0]
+
uint256
+
The amount still delegated (in case the list of delegates was incomplete).
Update vote powers when tokens are transferred.
+Also update delegated vote powers for percentage delegation
+and check for enough funds for explicit delegations.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_from
+
address
+
Source account of the transfer.
+
+
+
_to
+
address
+
Destination account of the transfer.
+
+
+
_fromBalance
+
uint256
+
Balance of the source account before the transfer.
+
+
+
_toBalance
+
uint256
+
Balance of the destination account before the transfer.
Delete vote power cache entry that expired (i.e. is before cleanupBlockNumber).
+Method can only be called from the cleanerContract (which may be a proxy to external cleaners).
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_owner
+
address
+
Vote power owner account address.
+
+
+
_blockNumber
+
uint256
+
Block number for which total supply value was cached.
Delete vote power checkpoints that expired (i.e. are before cleanupBlockNumber).
+Method can only be called from the cleanerContract (which may be a proxy to external cleaners).
Return true if this IIVPContract is configured to be used as a replacement for other contract.
+It means that vote powers are not necessarily correct at the initialization, therefore
+every method that reads vote power must check whether it is initialized for that address and block.
The VPToken (or some other contract) that owns this VPContract.
+All state changing methods may be called only from this address.
+This is because original msg.sender is typically sent in a parameter
+and we must make sure that it cannot be faked by directly calling
+IIVPContract methods.
+Owner token is also used in case of replacement to recover vote powers from balances.
An ERC20 token that enables the holder to delegate a voting power
+equal to their balance, with history tracking by block height.
+Actual vote power and delegation functionality is implemented in an associated VPContract.
Sets amount as the allowance of spender over the caller's tokens.
+
Returns a boolean value indicating whether the operation succeeded.
+
IMPORTANT: Beware that changing an allowance with this method brings the risk
+that someone may use both the old and the new allowance by unfortunate
+transaction ordering. One possible solution to mitigate this race
+condition is to first reduce the spender's allowance to 0 and set the
+desired value afterwards:
+https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
Delete balance checkpoints that expired (i.e. are before cleanupBlockNumber).
+Method can only be called from the cleanerContract (which may be a proxy to external cleaners).
Undelegate all percentage delegations from the sender and then delegate corresponding
+ _bips percentage of voting power from the sender to each member of the _delegatees array.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_delegatees
+
address[]
+
The addresses of the new recipients.
+
+
+
_bips
+
uint256[]
+
The percentages of voting power to be delegated expressed in basis points (1/100 of one percent). The sum of all _bips values must be at most 10000 (100%).
Returns the number of decimals used to get its user representation.
+For example, if decimals equals 2, a balance of 505 tokens should
+be displayed to a user as 5.05 (505 / 102).
+
Tokens usually opt for a value of 18, imitating the relationship between
+Ether and wei. This is the default value returned by this function, unless
+it's overridden.
+
NOTE: This information is only used for display purposes: it in
+no way affects any of the arithmetic of the contract, including
+balanceOf and transfer.
Delegate voting power to account _to from msg.sender, by percentage.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_to
+
address
+
The address of the recipient.
+
+
+
_bips
+
uint256
+
The percentage of voting power to be delegated expressed in basis points (1/100 of one percent). Not cumulative: every call resets the delegation value (and a value of 0 revokes all previous delegations).
Explicitly delegate_amount voting power to account _to from msg.sender.
+Compare with delegate which delegates by percentage.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_to
+
address
+
The address of the recipient.
+
+
+
_amount
+
uint256
+
An explicit vote power amount to be delegated. Not cumulative: every call resets the delegation value (and a value of 0 revokes all previous delegations).
Get the list of addresses to which _who is delegating, and their percentages.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_owner
+
address
+
+
+
+
+
+
+
+
Returns
+
Type
+
Description
+
+
+
+
+
_delegateAddresses
+
address[]
+
Positional array of addresses being delegated to.
+
+
+
_bips
+
uint256[]
+
Positional array of delegation percents specified in basis points (1/100 of 1 percent). Each one matches the address in the same position in the _delegateAddresses array.
Get the list of addresses to which _who is delegating, and their percentages, at the given block.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_owner
+
address
+
+
+
+
_blockNumber
+
uint256
+
The block number to query.
+
+
+
+
+
+
+
Returns
+
Type
+
Description
+
+
+
+
+
_delegateAddresses
+
address[]
+
Positional array of addresses being delegated to.
+
+
+
_bips
+
uint256[]
+
Positional array of delegation percents specified in basis points (1/100 of 1 percent). Each one matches the address in the same position in the _delegateAddresses array.
Get the delegation mode for account '_who'. This mode determines whether vote power is
+allocated by percentage or by explicit amount. Once the delegation mode is set,
+it can never be changed, even if all delegations are removed.
Returns VPContract event interface used for read-only operations (view methods).
+The only non-view method that might be called on it is revokeDelegationAt.
Do not call any methods on VPContract directly.
+State changing methods are forbidden from direct calls.
+All methods are exposed via VPToken.
+This is the reason that this method returns IVPContractEvents.
+Use it only for listening to events and revoking.
Revoke all delegation from sender to _who at given block.
+Only affects the reads via votePowerOfAtCached in the block _blockNumber.
+Block _blockNumber must be in the past.
+This method should be used only to prevent rogue delegate voting in the current voting block.
+To stop delegating use delegate / delegateExplicit with value of 0 or undelegateAll / undelegateAllExplicit.
Set the cleanup block number.
+Historic data for the blocks before cleanupBlockNumber can be erased.
+History before that block should never be used since it can be inconsistent.
+In particular, cleanup block number must be lower than the current vote power block.
Read VPContract must be set before any of the VPToken delegation or vote power reading methods are called,
+otherwise they will revert.
+
NOTE: If readVpContract differs from writeVpContract all reads will be "frozen" and will not reflect
+changes (not even revokes; they may or may not reflect balance transfers).
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_vpContract
+
contract IIVPContract
+
Read vote power contract to be used by this token.
Delete total supply cache entry that expired (i.e. is before cleanupBlockNumber).
+Method can only be called from the cleanerContract (which may be a proxy to external cleaners).
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_blockNumber
+
uint256
+
the block number for which total supply value was cached
+
+
+
+
+
+
+
Returns
+
Type
+
Description
+
+
+
+
+
[0]
+
uint256
+
the number of cache entries deleted (always 0 or 1)
Delete total supply checkpoints that expired (i.e. are before cleanupBlockNumber).
+Method can only be called from the cleanerContract (which may be a proxy to external cleaners).
Get the total vote power at block _blockNumber using cache.
+ It tries to read the cached value and if it is not found, reads the actual value and stores it in the cache.
+ Can only be used if _blockNumber is in the past, otherwise reverts.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_blockNumber
+
uint256
+
The block number to query.
+
+
+
+
+
+
+
Returns
+
Type
+
Description
+
+
+
+
+
[0]
+
uint256
+
The total vote power at the queried block (sum of all accounts' vote powers).
Undelegate all voting power of msg.sender. This effectively revokes all previous delegations.
+Can only be used with percentage delegation.
+Does not reset delegation mode back to NOT SET.
Undelegate all explicit vote power by amount of msg.sender.
+Can only be used with explicit delegation.
+Does not reset delegation mode back to NOT SET.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_delegateAddresses
+
address[]
+
Explicit delegation does not store delegatees' addresses, so the caller must supply them.
+
+
+
+
+
+
+
Returns
+
Type
+
Description
+
+
+
+
+
_remainingDelegation
+
uint256
+
The amount still delegated (in case the list of delegates was incomplete).
Get the vote power of _owner at block _blockNumber using cache.
+ It tries to read the cached value and if it is not found, reads the actual value and stores it in the cache.
+ Can only be used if _blockNumber is in the past, otherwise reverts.
Returns VPContract event interface used for state-changing operations (non-view methods).
+The only non-view method that might be called on it is revokeDelegationAt.
+
writeVotePowerContract is almost always equal to readVotePowerContract,
+except during upgrade from one VPContract to a new version (which should happen
+rarely or never and will be announced beforehand).
+In the case of an upgrade, writeVotePowerContract is replaced first to establish delegations.
+After some period (e.g., after a reward epoch ends), readVotePowerContract is set equal to it.
+
Do not call any methods on VPContract directly.
+State changing methods are forbidden from direct calls.
+All are exposed via VPToken.
+This is the reason that this method returns IVPContractEvents
+Use it only for listening to events, delegating, and revoking.
In case of providing bad prices (e.g. collusion), the voter can be chilled for a few reward epochs.
+A voter can whitelist again from a returned reward epoch onwards.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_voter
+
address
+
Address of the queried data provider.
+
+
+
+
+
+
+
Returns
+
Type
+
Description
+
+
+
+
+
[0]
+
uint256
+
uint256 ID of the epoch where the data provider can start submitting prices again.
Requests whitelisting an account to act as a data provider for a specific FTSO.
+Reverts if the vote power of the account is too low.
+May be called by any address, including the voter itself.
In case of providing bad prices (e.g. collusion), the voter can be chilled for a few reward epochs.
+A voter can whitelist again from a returned reward epoch onwards.
This contract converts native tokens into WNAT (wrapped native) tokens and vice versa.
+WNAT tokens are a one-to-one ERC20
+representation of native tokens, which are minted and burned as needed by this contract.
+
The wrapped versions of the native FLR and SGB tokens are called WFLR and WSGB respectively.
Sets amount as the allowance of spender over the caller's tokens.
+
Returns a boolean value indicating whether the operation succeeded.
+
IMPORTANT: Beware that changing an allowance with this method brings the risk
+that someone may use both the old and the new allowance by unfortunate
+transaction ordering. One possible solution to mitigate this race
+condition is to first reduce the spender's allowance to 0 and set the
+desired value afterwards:
+https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
Delete balance checkpoints that expired (i.e. are before cleanupBlockNumber).
+Method can only be called from the cleanerContract (which may be a proxy to external cleaners).
Undelegate all percentage delegations from the sender and then delegate corresponding
+ _bips percentage of voting power from the sender to each member of the _delegatees array.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_delegatees
+
address[]
+
The addresses of the new recipients.
+
+
+
_bips
+
uint256[]
+
The percentages of voting power to be delegated expressed in basis points (1/100 of one percent). The sum of all _bips values must be at most 10000 (100%).
Returns the number of decimals used to get its user representation.
+For example, if decimals equals 2, a balance of 505 tokens should
+be displayed to a user as 5.05 (505 / 102).
+
Tokens usually opt for a value of 18, imitating the relationship between
+Ether and wei. This is the default value returned by this function, unless
+it's overridden.
+
NOTE: This information is only used for display purposes: it in
+no way affects any of the arithmetic of the contract, including
+balanceOf and transfer.
Delegate voting power to account _to from msg.sender, by percentage.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_to
+
address
+
The address of the recipient.
+
+
+
_bips
+
uint256
+
The percentage of voting power to be delegated expressed in basis points (1/100 of one percent). Not cumulative: every call resets the delegation value (and a value of 0 revokes all previous delegations).
Explicitly delegate_amount voting power to account _to from msg.sender.
+Compare with delegate which delegates by percentage.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_to
+
address
+
The address of the recipient.
+
+
+
_amount
+
uint256
+
An explicit vote power amount to be delegated. Not cumulative: every call resets the delegation value (and a value of 0 revokes all previous delegations).
Get the list of addresses to which _who is delegating, and their percentages.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_owner
+
address
+
+
+
+
+
+
+
+
Returns
+
Type
+
Description
+
+
+
+
+
_delegateAddresses
+
address[]
+
Positional array of addresses being delegated to.
+
+
+
_bips
+
uint256[]
+
Positional array of delegation percents specified in basis points (1/100 of 1 percent). Each one matches the address in the same position in the _delegateAddresses array.
Get the list of addresses to which _who is delegating, and their percentages, at the given block.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_owner
+
address
+
+
+
+
_blockNumber
+
uint256
+
The block number to query.
+
+
+
+
+
+
+
Returns
+
Type
+
Description
+
+
+
+
+
_delegateAddresses
+
address[]
+
Positional array of addresses being delegated to.
+
+
+
_bips
+
uint256[]
+
Positional array of delegation percents specified in basis points (1/100 of 1 percent). Each one matches the address in the same position in the _delegateAddresses array.
Get the delegation mode for account '_who'. This mode determines whether vote power is
+allocated by percentage or by explicit amount. Once the delegation mode is set,
+it can never be changed, even if all delegations are removed.
Deposits native tokens and mints the same amount of WNAT tokens,
+which are added to the msg.sender's balance.
+This operation is commonly known as "wrapping".
Deposits native tokens and mints the same amount of WNAT tokens,
+which are added to _recipient's balance.
+This operation is commonly known as "wrapping".
Returns VPContract event interface used for read-only operations (view methods).
+The only non-view method that might be called on it is revokeDelegationAt.
Do not call any methods on VPContract directly.
+State changing methods are forbidden from direct calls.
+All methods are exposed via VPToken.
+This is the reason that this method returns IVPContractEvents.
+Use it only for listening to events and revoking.
Revoke all delegation from sender to _who at given block.
+Only affects the reads via votePowerOfAtCached in the block _blockNumber.
+Block _blockNumber must be in the past.
+This method should be used only to prevent rogue delegate voting in the current voting block.
+To stop delegating use delegate / delegateExplicit with value of 0 or undelegateAll / undelegateAllExplicit.
Set the cleanup block number.
+Historic data for the blocks before cleanupBlockNumber can be erased.
+History before that block should never be used since it can be inconsistent.
+In particular, cleanup block number must be lower than the current vote power block.
Read VPContract must be set before any of the VPToken delegation or vote power reading methods are called,
+otherwise they will revert.
+
NOTE: If readVpContract differs from writeVpContract all reads will be "frozen" and will not reflect
+changes (not even revokes; they may or may not reflect balance transfers).
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_vpContract
+
contract IIVPContract
+
Read vote power contract to be used by this token.
Delete total supply cache entry that expired (i.e. is before cleanupBlockNumber).
+Method can only be called from the cleanerContract (which may be a proxy to external cleaners).
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_blockNumber
+
uint256
+
the block number for which total supply value was cached
+
+
+
+
+
+
+
Returns
+
Type
+
Description
+
+
+
+
+
[0]
+
uint256
+
the number of cache entries deleted (always 0 or 1)
Delete total supply checkpoints that expired (i.e. are before cleanupBlockNumber).
+Method can only be called from the cleanerContract (which may be a proxy to external cleaners).
Get the total vote power at block _blockNumber using cache.
+ It tries to read the cached value and if it is not found, reads the actual value and stores it in the cache.
+ Can only be used if _blockNumber is in the past, otherwise reverts.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_blockNumber
+
uint256
+
The block number to query.
+
+
+
+
+
+
+
Returns
+
Type
+
Description
+
+
+
+
+
[0]
+
uint256
+
The total vote power at the queried block (sum of all accounts' vote powers).
Undelegate all voting power of msg.sender. This effectively revokes all previous delegations.
+Can only be used with percentage delegation.
+Does not reset delegation mode back to NOT SET.
Undelegate all explicit vote power by amount of msg.sender.
+Can only be used with explicit delegation.
+Does not reset delegation mode back to NOT SET.
+
+
+
+
Parameters
+
Type
+
Description
+
+
+
+
+
_delegateAddresses
+
address[]
+
Explicit delegation does not store delegatees' addresses, so the caller must supply them.
+
+
+
+
+
+
+
Returns
+
Type
+
Description
+
+
+
+
+
_remainingDelegation
+
uint256
+
The amount still delegated (in case the list of delegates was incomplete).
Get the vote power of _owner at block _blockNumber using cache.
+ It tries to read the cached value and if it is not found, reads the actual value and stores it in the cache.
+ Can only be used if _blockNumber is in the past, otherwise reverts.
Burns _amount of WNAT tokens from msg.sender's WNAT balance and
+transfers the same amount of native tokens to msg.sender.
+This operation is commonly known as "unwrapping".
+
Reverts if _amount is higher than msg.sender's WNAT balance.
Burns _amount of WNAT tokens from _owner's WNAT balance and
+transfers the same amount of native tokens to msg.sender.
+This operation is commonly known as "unwrapping".
+
msg.sender must have been authorized to withdraw from _owner's account
+through ERC-20's approve mechanism.
+
Reverts if _amount is higher than _owners's WNAT balance or than
+msg.sender's allowance over _owner's tokens.
Returns VPContract event interface used for state-changing operations (non-view methods).
+The only non-view method that might be called on it is revokeDelegationAt.
+
writeVotePowerContract is almost always equal to readVotePowerContract,
+except during upgrade from one VPContract to a new version (which should happen
+rarely or never and will be announced beforehand).
+In the case of an upgrade, writeVotePowerContract is replaced first to establish delegations.
+After some period (e.g., after a reward epoch ends), readVotePowerContract is set equal to it.
+
Do not call any methods on VPContract directly.
+State changing methods are forbidden from direct calls.
+All are exposed via VPToken.
+This is the reason that this method returns IVPContractEvents
+Use it only for listening to events, delegating, and revoking.
\n }\n \n \n )\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Render a search result\n *\n * @param result - Search result\n *\n * @returns Element\n */\nexport function renderSearchResultItem(\n result: SearchResultItem\n): HTMLElement {\n const threshold = result[0].score\n const docs = [...result]\n\n /* Find and extract parent article */\n const parent = docs.findIndex(doc => !doc.location.includes(\"#\"))\n const [article] = docs.splice(parent, 1)\n\n /* Determine last index above threshold */\n let index = docs.findIndex(doc => doc.score < threshold)\n if (index === -1)\n index = docs.length\n\n /* Partition sections */\n const best = docs.slice(0, index)\n const more = docs.slice(index)\n\n /* Render children */\n const children = [\n renderSearchDocument(article, Flag.PARENT | +(!parent && index === 0)),\n ...best.map(section => renderSearchDocument(section, Flag.TEASER)),\n ...more.length ? [\n \n \n {more.length > 0 && more.length === 1\n ? translation(\"search.result.more.one\")\n : translation(\"search.result.more.other\", more.length)\n }\n \n {...more.map(section => renderSearchDocument(section, Flag.TEASER))}\n \n ] : []\n ]\n\n /* Render search result */\n return (\n
\n {children}\n
\n )\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { SourceFacts } from \"~/components\"\nimport { h, round } from \"~/utilities\"\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Render repository facts\n *\n * @param facts - Repository facts\n *\n * @returns Element\n */\nexport function renderSourceFacts(facts: SourceFacts): HTMLElement {\n return (\n
\n {typeof value === \"number\" ? round(value) : value}\n
\n ))}\n
\n )\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { h } from \"~/utilities\"\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Tabbed control type\n */\ntype TabbedControlType =\n | \"prev\"\n | \"next\"\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Render control for content tabs\n *\n * @param type - Control type\n *\n * @returns Element\n */\nexport function renderTabbedControl(\n type: TabbedControlType\n): HTMLElement {\n const classes = `tabbed-control tabbed-control--${type}`\n return (\n
\n \n
\n )\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { h } from \"~/utilities\"\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Render a table inside a wrapper to improve scrolling on mobile\n *\n * @param table - Table element\n *\n * @returns Element\n */\nexport function renderTable(table: HTMLElement): HTMLElement {\n return (\n
\n
\n {table}\n
\n
\n )\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { configuration, translation } from \"~/_\"\nimport { h } from \"~/utilities\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Version\n */\nexport interface Version {\n version: string /* Version identifier */\n title: string /* Version title */\n aliases: string[] /* Version aliases */\n}\n\n/* ----------------------------------------------------------------------------\n * Helper functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Render a version\n *\n * @param version - Version\n *\n * @returns Element\n */\nfunction renderVersion(version: Version): HTMLElement {\n const config = configuration()\n\n /* Ensure trailing slash, see https://bit.ly/3rL5u3f */\n const url = new URL(`../${version.version}/`, config.base)\n return (\n
\n )\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Render a version selector\n *\n * @param versions - Versions\n * @param active - Active version\n *\n * @returns Element\n */\nexport function renderVersionSelector(\n versions: Version[], active: Version\n): HTMLElement {\n return (\n
\n \n
\n {versions.map(renderVersion)}\n
\n
\n )\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n EMPTY,\n Observable,\n Subject,\n animationFrameScheduler,\n combineLatest,\n defer,\n finalize,\n fromEvent,\n map,\n switchMap,\n take,\n takeLast,\n takeUntil,\n tap,\n throttleTime\n} from \"rxjs\"\n\nimport {\n ElementOffset,\n getElement,\n getElementSize,\n watchElementContentOffset,\n watchElementFocus,\n watchElementOffset,\n watchElementVisibility\n} from \"~/browser\"\n\nimport { Component } from \"../../../_\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Annotation\n */\nexport interface Annotation {\n active: boolean /* Annotation is active */\n offset: ElementOffset /* Annotation offset */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch annotation\n *\n * @param el - Annotation element\n * @param container - Containing element\n *\n * @returns Annotation observable\n */\nexport function watchAnnotation(\n el: HTMLElement, container: HTMLElement\n): Observable {\n const offset$ = defer(() => combineLatest([\n watchElementOffset(el),\n watchElementContentOffset(container)\n ]))\n .pipe(\n map(([{ x, y }, scroll]) => {\n const { width } = getElementSize(el)\n return ({\n x: x - scroll.x + width / 2,\n y: y - scroll.y\n })\n })\n )\n\n /* Actively watch annotation on focus */\n return watchElementFocus(el)\n .pipe(\n switchMap(active => offset$\n .pipe(\n map(offset => ({ active, offset })),\n take(+!active || Infinity)\n )\n )\n )\n}\n\n/**\n * Mount annotation\n *\n * @param el - Annotation element\n * @param container - Containing element\n *\n * @returns Annotation component observable\n */\nexport function mountAnnotation(\n el: HTMLElement, container: HTMLElement\n): Observable> {\n return defer(() => {\n const push$ = new Subject()\n push$.subscribe({\n\n /* Handle emission */\n next({ offset }) {\n el.style.setProperty(\"--md-tooltip-x\", `${offset.x}px`)\n el.style.setProperty(\"--md-tooltip-y\", `${offset.y}px`)\n },\n\n /* Handle complete */\n complete() {\n el.style.removeProperty(\"--md-tooltip-x\")\n el.style.removeProperty(\"--md-tooltip-y\")\n }\n })\n\n /* Start animation only when annotation is visible */\n const done$ = push$.pipe(takeLast(1))\n watchElementVisibility(el)\n .pipe(\n takeUntil(done$)\n )\n .subscribe(visible => {\n el.toggleAttribute(\"data-md-visible\", visible)\n })\n\n /* Track relative origin of tooltip */\n push$\n .pipe(\n throttleTime(500, animationFrameScheduler),\n map(() => container.getBoundingClientRect()),\n map(({ x }) => x)\n )\n .subscribe({\n\n /* Handle emission */\n next(origin) {\n if (origin)\n el.style.setProperty(\"--md-tooltip-0\", `${-origin}px`)\n else\n el.style.removeProperty(\"--md-tooltip-0\")\n },\n\n /* Handle complete */\n complete() {\n el.style.removeProperty(\"--md-tooltip-0\")\n }\n })\n\n /* Close open annotation on click */\n const index = getElement(\":scope > :last-child\", el)\n const blur$ = fromEvent(index, \"mousedown\", { once: true })\n push$\n .pipe(\n switchMap(({ active }) => active ? blur$ : EMPTY),\n tap(ev => ev.preventDefault())\n )\n .subscribe(() => el.blur())\n\n /* Create and return component */\n return watchAnnotation(el, container)\n .pipe(\n tap(state => push$.next(state)),\n finalize(() => push$.complete()),\n map(state => ({ ref: el, ...state }))\n )\n })\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n EMPTY,\n Observable,\n Subject,\n defer,\n finalize,\n merge,\n share,\n takeLast,\n takeUntil\n} from \"rxjs\"\n\nimport {\n getElement,\n getElements,\n getOptionalElement\n} from \"~/browser\"\nimport { renderAnnotation } from \"~/templates\"\n\nimport { Component } from \"../../../_\"\nimport {\n Annotation,\n mountAnnotation\n} from \"../_\"\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Mount options\n */\ninterface MountOptions {\n print$: Observable /* Media print observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Helper functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Find all annotation markers in the given code block\n *\n * @param container - Containing element\n *\n * @returns Annotation markers\n */\nfunction findAnnotationMarkers(container: HTMLElement): Text[] {\n const markers: Text[] = []\n for (const comment of getElements(\".c, .c1, .cm\", container)) {\n let match: RegExpExecArray | null\n\n /* Split text at marker and add to list */\n let text = comment.firstChild as Text\n if (text instanceof Text)\n while ((match = /\\((\\d+)\\)/.exec(text.textContent!))) {\n const marker = text.splitText(match.index)\n text = marker.splitText(match[0].length)\n markers.push(marker)\n }\n }\n return markers\n}\n\n/**\n * Swap the child nodes of two elements\n *\n * @param source - Source element\n * @param target - Target element\n */\nfunction swap(source: HTMLElement, target: HTMLElement): void {\n target.append(...Array.from(source.childNodes))\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Mount annotation list\n *\n * This function analyzes the containing code block and checks for markers\n * referring to elements in the given annotation list. If no markers are found,\n * the list is left untouched. Otherwise, list elements are rendered as\n * annotations inside the code block.\n *\n * @param el - Annotation list element\n * @param container - Containing element\n * @param options - Options\n *\n * @returns Annotation component observable\n */\nexport function mountAnnotationList(\n el: HTMLElement, container: HTMLElement, { print$ }: MountOptions\n): Observable> {\n\n /* Find and replace all markers with empty annotations */\n const annotations = new Map()\n for (const marker of findAnnotationMarkers(container)) {\n const [, id] = marker.textContent!.match(/\\((\\d+)\\)/)!\n if (getOptionalElement(`li:nth-child(${id})`, el)) {\n annotations.set(+id, renderAnnotation(+id))\n marker.replaceWith(annotations.get(+id)!)\n }\n }\n\n /* Keep list if there are no annotations to render */\n if (annotations.size === 0)\n return EMPTY\n\n /* Create and return component */\n return defer(() => {\n const done$ = new Subject()\n\n /* Handle print mode - see https://bit.ly/3rgPdpt */\n print$\n .pipe(\n takeUntil(done$.pipe(takeLast(1)))\n )\n .subscribe(active => {\n el.hidden = !active\n\n /* Show annotations in code block or list (print) */\n for (const [id, annotation] of annotations) {\n const inner = getElement(\".md-typeset\", annotation)\n const child = getElement(`li:nth-child(${id})`, el)\n if (!active)\n swap(child, inner)\n else\n swap(inner, child)\n }\n })\n\n /* Create and return component */\n return merge(...[...annotations]\n .map(([, annotation]) => (\n mountAnnotation(annotation, container)\n ))\n )\n .pipe(\n finalize(() => done$.complete()),\n share()\n )\n })\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n Observable,\n map,\n of,\n shareReplay,\n tap\n} from \"rxjs\"\n\nimport { watchScript } from \"~/browser\"\nimport { h } from \"~/utilities\"\n\nimport { Component } from \"../../../_\"\n\nimport themeCSS from \"./index.css\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Mermaid diagram\n */\nexport interface Mermaid {}\n\n/* ----------------------------------------------------------------------------\n * Data\n * ------------------------------------------------------------------------- */\n\n/**\n * Mermaid instance observable\n */\nlet mermaid$: Observable\n\n/**\n * Global sequence number for diagrams\n */\nlet sequence = 0\n\n/* ----------------------------------------------------------------------------\n * Helper functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Fetch Mermaid script\n *\n * @returns Mermaid scripts observable\n */\nfunction fetchScripts(): Observable {\n return typeof mermaid === \"undefined\" || mermaid instanceof Element\n ? watchScript(\"https://unpkg.com/mermaid@9.0.1/dist/mermaid.min.js\")\n : of(undefined)\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Mount Mermaid diagram\n *\n * @param el - Code block element\n *\n * @returns Mermaid diagram component observable\n */\nexport function mountMermaid(\n el: HTMLElement\n): Observable> {\n el.classList.remove(\"mermaid\") // Hack: mitigate https://bit.ly/3CiN6Du\n mermaid$ ||= fetchScripts()\n .pipe(\n tap(() => mermaid.initialize({\n startOnLoad: false,\n themeCSS\n })),\n map(() => undefined),\n shareReplay(1)\n )\n\n /* Render diagram */\n mermaid$.subscribe(() => {\n el.classList.add(\"mermaid\") // Hack: mitigate https://bit.ly/3CiN6Du\n const id = `__mermaid_${sequence++}`\n const host = h(\"div\", { class: \"mermaid\" })\n mermaid.mermaidAPI.render(id, el.textContent, (svg: string) => {\n\n /* Create a shadow root and inject diagram */\n const shadow = host.attachShadow({ mode: \"closed\" })\n shadow.innerHTML = svg\n\n /* Replace code block with diagram */\n el.replaceWith(host)\n })\n })\n\n /* Create and return component */\n return mermaid$\n .pipe(\n map(() => ({ ref: el }))\n )\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n Observable,\n Subject,\n defer,\n filter,\n finalize,\n map,\n merge,\n tap\n} from \"rxjs\"\n\nimport { Component } from \"../../_\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Details\n */\nexport interface Details {\n action: \"open\" | \"close\" /* Details state */\n reveal?: boolean /* Details is revealed */\n}\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch options\n */\ninterface WatchOptions {\n target$: Observable /* Location target observable */\n print$: Observable /* Media print observable */\n}\n\n/**\n * Mount options\n */\ninterface MountOptions {\n target$: Observable /* Location target observable */\n print$: Observable /* Media print observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch details\n *\n * @param el - Details element\n * @param options - Options\n *\n * @returns Details observable\n */\nexport function watchDetails(\n el: HTMLDetailsElement, { target$, print$ }: WatchOptions\n): Observable {\n let open = true\n return merge(\n\n /* Open and focus details on location target */\n target$\n .pipe(\n map(target => target.closest(\"details:not([open])\")!),\n filter(details => el === details),\n map(() => ({\n action: \"open\", reveal: true\n }) as Details)\n ),\n\n /* Open details on print and close afterwards */\n print$\n .pipe(\n filter(active => active || !open),\n tap(() => open = el.open),\n map(active => ({\n action: active ? \"open\" : \"close\"\n }) as Details)\n )\n )\n}\n\n/**\n * Mount details\n *\n * This function ensures that `details` tags are opened on anchor jumps and\n * prior to printing, so the whole content of the page is visible.\n *\n * @param el - Details element\n * @param options - Options\n *\n * @returns Details component observable\n */\nexport function mountDetails(\n el: HTMLDetailsElement, options: MountOptions\n): Observable> {\n return defer(() => {\n const push$ = new Subject()\n push$.subscribe(({ action, reveal }) => {\n if (action === \"open\")\n el.setAttribute(\"open\", \"\")\n else\n el.removeAttribute(\"open\")\n if (reveal)\n el.scrollIntoView()\n })\n\n /* Create and return component */\n return watchDetails(el, options)\n .pipe(\n tap(state => push$.next(state)),\n finalize(() => push$.complete()),\n map(state => ({ ref: el, ...state }))\n )\n })\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { Observable, of } from \"rxjs\"\n\nimport { renderTable } from \"~/templates\"\nimport { h } from \"~/utilities\"\n\nimport { Component } from \"../../_\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Data table\n */\nexport interface DataTable {}\n\n/* ----------------------------------------------------------------------------\n * Data\n * ------------------------------------------------------------------------- */\n\n/**\n * Sentinel for replacement\n */\nconst sentinel = h(\"table\")\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Mount data table\n *\n * This function wraps a data table in another scrollable container, so it can\n * be smoothly scrolled on smaller screen sizes and won't break the layout.\n *\n * @param el - Data table element\n *\n * @returns Data table component observable\n */\nexport function mountDataTable(\n el: HTMLElement\n): Observable> {\n el.replaceWith(sentinel)\n sentinel.replaceWith(renderTable(el))\n\n /* Create and return component */\n return of({ ref: el })\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n Observable,\n Subject,\n animationFrameScheduler,\n asyncScheduler,\n auditTime,\n combineLatest,\n defer,\n finalize,\n fromEvent,\n map,\n merge,\n skip,\n startWith,\n subscribeOn,\n takeLast,\n takeUntil,\n tap\n} from \"rxjs\"\n\nimport { feature } from \"~/_\"\nimport {\n getElement,\n getElementContentOffset,\n getElementContentSize,\n getElementOffset,\n getElementSize,\n getElements,\n watchElementContentOffset,\n watchElementSize\n} from \"~/browser\"\nimport { renderTabbedControl } from \"~/templates\"\n\nimport { Component } from \"../../_\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Content tabs\n */\nexport interface ContentTabs {\n active: HTMLLabelElement /* Active tab label */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch content tabs\n *\n * @param el - Content tabs element\n *\n * @returns Content tabs observable\n */\nexport function watchContentTabs(\n el: HTMLElement\n): Observable {\n const inputs = getElements(\":scope > input\", el)\n const initial = inputs.find(input => input.checked) || inputs[0]\n return merge(...inputs.map(input => fromEvent(input, \"change\")\n .pipe(\n map(() => getElement(`label[for=\"${input.id}\"]`))\n )\n ))\n .pipe(\n startWith(getElement(`label[for=\"${initial.id}\"]`)),\n map(active => ({ active }))\n )\n}\n\n/**\n * Mount content tabs\n *\n * This function scrolls the active tab into view. While this functionality is\n * provided by browsers as part of `scrollInfoView`, browsers will always also\n * scroll the vertical axis, which we do not want. Thus, we decided to provide\n * this functionality ourselves.\n *\n * @param el - Content tabs element\n *\n * @returns Content tabs component observable\n */\nexport function mountContentTabs(\n el: HTMLElement\n): Observable> {\n\n /* Render content tab previous button for pagination */\n const prev = renderTabbedControl(\"prev\")\n el.append(prev)\n\n /* Render content tab next button for pagination */\n const next = renderTabbedControl(\"next\")\n el.append(next)\n\n /* Mount component on subscription */\n const container = getElement(\".tabbed-labels\", el)\n return defer(() => {\n const push$ = new Subject()\n const done$ = push$.pipe(takeLast(1))\n combineLatest([push$, watchElementSize(el)])\n .pipe(\n auditTime(1, animationFrameScheduler),\n takeUntil(done$)\n )\n .subscribe({\n\n /* Handle emission */\n next([{ active }, size]) {\n const offset = getElementOffset(active)\n const { width } = getElementSize(active)\n\n /* Set tab indicator offset and width */\n el.style.setProperty(\"--md-indicator-x\", `${offset.x}px`)\n el.style.setProperty(\"--md-indicator-width\", `${width}px`)\n\n /* Scroll container to active content tab */\n const content = getElementContentOffset(container)\n if (\n offset.x < content.x ||\n offset.x + width > content.x + size.width\n )\n container.scrollTo({\n left: Math.max(0, offset.x - 16),\n behavior: \"smooth\"\n })\n },\n\n /* Handle complete */\n complete() {\n el.style.removeProperty(\"--md-indicator-x\")\n el.style.removeProperty(\"--md-indicator-width\")\n }\n })\n\n /* Hide content tab buttons on borders */\n combineLatest([\n watchElementContentOffset(container),\n watchElementSize(container)\n ])\n .pipe(\n takeUntil(done$)\n )\n .subscribe(([offset, size]) => {\n const content = getElementContentSize(container)\n prev.hidden = offset.x < 16\n next.hidden = offset.x > content.width - size.width - 16\n })\n\n /* Paginate content tab container on click */\n merge(\n fromEvent(prev, \"click\").pipe(map(() => -1)),\n fromEvent(next, \"click\").pipe(map(() => +1))\n )\n .pipe(\n takeUntil(done$)\n )\n .subscribe(direction => {\n const { width } = getElementSize(container)\n container.scrollBy({\n left: width * direction,\n behavior: \"smooth\"\n })\n })\n\n /* Set up linking of content tabs, if enabled */\n if (feature(\"content.tabs.link\"))\n push$.pipe(skip(1))\n .subscribe(({ active }) => {\n const tab = active.innerText.trim()\n for (const set of getElements(\"[data-tabs]\"))\n for (const input of getElements(\n \":scope > input\", set\n )) {\n const label = getElement(`label[for=\"${input.id}\"]`)\n if (label.innerText.trim() === tab) {\n input.click()\n break\n }\n }\n\n /* Persist active tabs in local storage */\n const tabs = __md_get(\"__tabs\") || []\n __md_set(\"__tabs\", [...new Set([tab, ...tabs])])\n })\n\n /* Create and return component */\n return watchContentTabs(el)\n .pipe(\n tap(state => push$.next(state)),\n finalize(() => push$.complete()),\n map(state => ({ ref: el, ...state }))\n )\n })\n .pipe(\n subscribeOn(asyncScheduler)\n )\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { Observable, merge } from \"rxjs\"\n\nimport { getElements } from \"~/browser\"\n\nimport { Component } from \"../../_\"\nimport { Annotation } from \"../annotation\"\nimport {\n CodeBlock,\n Mermaid,\n mountCodeBlock,\n mountMermaid\n} from \"../code\"\nimport {\n Details,\n mountDetails\n} from \"../details\"\nimport {\n DataTable,\n mountDataTable\n} from \"../table\"\nimport {\n ContentTabs,\n mountContentTabs\n} from \"../tabs\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Content\n */\nexport type Content =\n | Annotation\n | ContentTabs\n | CodeBlock\n | Mermaid\n | DataTable\n | Details\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Mount options\n */\ninterface MountOptions {\n target$: Observable /* Location target observable */\n print$: Observable /* Media print observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Mount content\n *\n * This function mounts all components that are found in the content of the\n * actual article, including code blocks, data tables and details.\n *\n * @param el - Content element\n * @param options - Options\n *\n * @returns Content component observable\n */\nexport function mountContent(\n el: HTMLElement, { target$, print$ }: MountOptions\n): Observable> {\n return merge(\n\n /* Code blocks */\n ...getElements(\"pre:not(.mermaid) > code\", el)\n .map(child => mountCodeBlock(child, { print$ })),\n\n /* Mermaid diagrams */\n ...getElements(\"pre.mermaid\", el)\n .map(child => mountMermaid(child)),\n\n /* Data tables */\n ...getElements(\"table:not([class])\", el)\n .map(child => mountDataTable(child)),\n\n /* Details */\n ...getElements(\"details\", el)\n .map(child => mountDetails(child, { target$, print$ })),\n\n /* Content tabs */\n ...getElements(\"[data-tabs]\", el)\n .map(child => mountContentTabs(child))\n )\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n Observable,\n Subject,\n defer,\n delay,\n finalize,\n map,\n merge,\n of,\n switchMap,\n tap\n} from \"rxjs\"\n\nimport { getElement } from \"~/browser\"\n\nimport { Component } from \"../_\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Dialog\n */\nexport interface Dialog {\n message: string /* Dialog message */\n active: boolean /* Dialog is active */\n}\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch options\n */\ninterface WatchOptions {\n alert$: Subject /* Alert subject */\n}\n\n/**\n * Mount options\n */\ninterface MountOptions {\n alert$: Subject /* Alert subject */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch dialog\n *\n * @param _el - Dialog element\n * @param options - Options\n *\n * @returns Dialog observable\n */\nexport function watchDialog(\n _el: HTMLElement, { alert$ }: WatchOptions\n): Observable