Add throttle interface

This commit is contained in:
lash 2023-08-04 18:17:23 +01:00
parent db35d389ec
commit b1c03932ad
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
6 changed files with 97 additions and 0 deletions

View File

@ -654,6 +654,36 @@ Use cases of sealing include:
<https://git.grassecon.net/cicnet/erc20-demurrage-token.git> <https://git.grassecon.net/cicnet/erc20-demurrage-token.git>
### Throttle
An backend contract to limit access to a resource by time.
The smart contract managing the resource calls have(address) on this
contract to check if it can be made use of at the current point in time.
This also implements [ACL](#acl).
When the resource is made use of, it calls poke(address) method to
register when it has been made use of.
#### ERC165 Interface identifier
8f5bc7bf
#### Solidity interface definition
interface IThrottle {
// Returns true if the given address is authorized to make use of the resource at the current moment.
// Implements ACL
function have(address _address) external view returns(bool);
// Must be called when the resource is being used.
function poke(address _address) external returns(bool);
}
#### Reference implementation
<git://holbrook.no/eth-faucet.git> (PeriodSimple contract)
### TokenLimit ### TokenLimit
Define limits of value amounts of tokens that individual addresses can Define limits of value amounts of tokens that individual addresses can

View File

@ -1,3 +1,4 @@
@anchor{acl}
@subsection ACL @subsection ACL
A simple Access Control List definition that returns true of false depending on whether an signatory (address) is allowed to operate in a given context. A simple Access Control List definition that returns true of false depending on whether an signatory (address) is allowed to operate in a given context.

View File

@ -76,6 +76,8 @@ The following well-known solidity interfaces are partially implemented in CIC na
@include seal.sol.texi @include seal.sol.texi
@include throttle.sol.texi
@include tokenlimit.sol.texi @include tokenlimit.sol.texi
@include tokenquote.sol.texi @include tokenquote.sol.texi

View File

@ -0,0 +1,20 @@
@subsection Throttle
An backend contract to limit access to a resource by time.
The smart contract managing the resource calls `have(address)` on this contract to check if it can be made use of at the current point in time. This also implements @ref{acl, ACL}.
When the resource is made use of, it calls `poke(address)` method to register when it has been made use of.
@subsubsection ERC165 Interface identifier
@include ../../build/Throttle.interface
@subsubsection Solidity interface definition
@include ../../build/contract_Throttle.texi
@subsubsection Reference implementation
@uref{git://holbrook.no/eth-faucet.git,} (PeriodSimple contract)

View File

@ -654,6 +654,36 @@ Use cases of sealing include:
<https://git.grassecon.net/cicnet/erc20-demurrage-token.git> <https://git.grassecon.net/cicnet/erc20-demurrage-token.git>
### Throttle
An backend contract to limit access to a resource by time.
The smart contract managing the resource calls have(address) on this
contract to check if it can be made use of at the current point in time.
This also implements [ACL](#acl).
When the resource is made use of, it calls poke(address) method to
register when it has been made use of.
#### ERC165 Interface identifier
8f5bc7bf
#### Solidity interface definition
interface IThrottle {
// Returns true if the given address is authorized to make use of the resource at the current moment.
// Implements ACL
function have(address _address) external view returns(bool);
// Must be called when the resource is being used.
function poke(address _address) external returns(bool);
}
#### Reference implementation
<git://holbrook.no/eth-faucet.git> (PeriodSimple contract)
### TokenLimit ### TokenLimit
Define limits of value amounts of tokens that individual addresses can Define limits of value amounts of tokens that individual addresses can

14
solidity/Throttle.sol Normal file
View File

@ -0,0 +1,14 @@
pragma solidity >=0.6.12;
// Author: Louis Holbrook <dev@holbrook.no> 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
// SPDX-License-Identifier: AGPL-3.0-or-later
// File-version: 1
interface IThrottle {
// Returns true if the given address is authorized to make use of the resource at the current moment.
// Implements ACL
function have(address _address) external view returns(bool);
// Must be called when the resource is being used.
function poke(address _address) external returns(bool);
}