Merge branch 'dev-0.2.1'

This commit is contained in:
lash 2023-05-07 19:02:58 +01:00
commit 2c666cc2aa
54 changed files with 978 additions and 120 deletions

5
.gitignore vendored
View File

@ -3,4 +3,7 @@ gmon.out
dist
build
*.egg-info
.venv
.venv
solidity/*.json
solidity/*.interface
solidity/*.bin

View File

@ -19,14 +19,25 @@ PREFIX = /usr/local/share/cic/solidity/abi
.sol.interface:
bash to_interface.sh $(basename $@).sol > $@
all: $(OUTPUTS)
all: outs doc
outs: $(OUTPUTS)
echo $(OUTPUTS)
install: $(OUTPUTS)
install-code: $(OUTPUTS)
install -vDm0644 -t $(PREFIX) $?
install-doc:
bash texify.sh
install: outs install-code install-doc doc
clean:
rm -vf solidity/*.json
rm -vf solidity/*.interface
doc:
bash texify.sh
make -C doc/texinfo
.PHONY: clean install

View File

@ -1 +1 @@
0.0.5
0.2.0

View File

@ -0,0 +1,36 @@
@subsection Accounts Index
Append-only list of addresses. Typically used for access control lists.
Addresses may be @emph{added}, @emph{removed}, aswell as @emph{deactivated} and @emph{activated}. Deactivated accounts still count towards the @code{entryCount}.
The @code{entry} method is used to iterate the account list. The order of which accounts are returned is not guaranteed. Any returned value matching @code{address(0x00)} should be skipped, and not counted towards @code{entryCount}.
May optionally record time when account was added.
@table @dfn
@item ERC165 Interface identifier
@include ../../build/AccountsIndex.interface
@item Solidity interface definition
@include ../../build/contract_AccountsIndex.texi
@item Reference implementation
@uref{git://holbrook.no/eth-accounts-index.git,} (v0.5.1)
@end table
@subsection Accounts Index Mutable
Extends the functionality of @code{Accounts Index} to allow changes to the address list.
Addresses may be @emph{added}, @emph{removed}, aswell as @emph{deactivated} and @emph{activated}. Deactivated accounts still count towards the @code{entryCount}.
@table @dfn
@item ERC165 Interface identifier
@include ../../build/AccountsIndexMutable.interface
@item Solidity interface definition
@include ../../build/contract_AccountsIndexMutable.texi
@item Reference implementation
@uref{git://holbrook.no/eth-accounts-index.git,} (v0.5.1)
@end table

View File

@ -0,0 +1,14 @@
@subsection Burner
Attached to @code{ERC20} and @code{ERC721} tokens that may be @emph{burned}.
Implements the @code{burn(...)} part of @code{ERC5679} for interoperability.
@table @dfn
@item ERC165 Interface identifier
@include ../../build/Burner.interface
@item Solidity interface definition
@include ../../build/contract_Burner.texi
@item Example implementation
@uref{https://git.grassecon.net/cicnet/erc20-demurrage-token.git}
@end table

View File

@ -0,0 +1,15 @@
@subsection Chrono
Define a creation time for a resource.
Complements @code{ERC5007}.
@table @dfn
@item ERC165 Interface identifier
@include ../../build/Chrono.interface
@item Solidity interface definition
@include ../../build/contract_Chrono.texi
@item Example implementation
@uref{https://git.defalsify.org/eth-erc721} (BadgeToken contract)
@end table

View File

@ -0,0 +1,20 @@
@subsection Declarator
Permissionless store of signed claims made by an address about other addresses, or addresses about themselves.
It is used to declare or respond to certifications of vouchers, NFT, voucher members.
Addresses may be Externally Owned Accounts or smart contracts.
Claims may be made with or without topics. A missing topic is synonymous with a topic value of @code{bytes32(0x00)}.
Any number of claims can be made about an address under any number of topics. All claims must be stored, and returned in the order which they were added.
@table @dfn
@item ERC165 Interface identifier
@include ../../build/Declarator.interface
@item Solidity interface definition
@include ../../build/contract_Declarator.texi
@item Reference implementation
@uref{git://holbrook.no/eth-address-index.git,}
@end table

View File

@ -0,0 +1,17 @@
@subsection Digest
Allows encoding of digests according to a specific encoding scheme.
Primary use-case is the abstraction of self-describing @uref{https://multiformats.io/multihash/,Multhash} encoding.
A default encoding @emph{must} always be defined, and the encoding of a valid digest @emph{must} succeed with the default encoding.
@table @dfn
@item ERC165 Interface identifier
@include ../../build/Digest.interface
@item Solidity interface definition
@include ../../build/contract_Digest.texi
@item Example implementation
@uref{git://holbrook.no/eth-event-msg.git}
@end table

View File

@ -0,0 +1,15 @@
@subsection Expire
Defines an expiry time after which token balances or supply @emph{cannot change}.
A contract defining an expiry @emph{must not} allow changing the expiration time to a time in the past.
@table @dfn
@item ERC165 Interface identifier
@include ../../build/Expire.interface
@item Solidity interface definition
@include ../../build/contract_Expire.texi
@item Example implementation
@uref{https://git.grassecon.net/cicnet/erc20-demurrage-token.git}
@end table

View File

@ -0,0 +1,39 @@
@subsection Faucet
Used for dispensing tokens to any address.
It can be used for gas tokens and @emph{ERC20} alike.
The interface is the same whether the faucet is dispensing from existing balance or minting new tokens.
The value dispersed @emph{must} be the same for all addresses.
In general, four criteria are expected to exist in any combination for limiting access to the faucet:
@table @dfn
@item Time
A recipient may only use the faucet again after some time has passed.
@item Balance threshold
A recipient may only use the faucet after its balance is below a certain amount.
@item Membership
A recipient may only use the faucet if it has been added to an access control list.
@item Capacity
The contract has sufficient token funds to dispense the current defined amount to dispense.
@end table
The @emph{check(address)} contract call @emph{must} evaluate all four criteria, and @emph{must} return @code{false} if any of the criteria are not met.
@table @dfn
@item ERC165 Interface identifier
@include ../../build/Faucet.interface
@item Solidity interface definition
@include ../../build/contract_Faucet.texi
@item Reference implementations
@itemize
@item
@uref{git://holbrook.no/erc20-faucet.git,}
@item
@uref{git://holbrook.no/eth-faucet.git,}
@end itemize
@end table

View File

@ -0,0 +1,60 @@
@subsection Locator
This interface supports @code{ERC721 Metadata}, in particular the @code{tokenURI(uint256)} call.
Off-chain resources in the CIC network @emph{must} be defined in terms of content addressed strings.
It @emph{must} be possible to refer to all off-chain resources directly by the content address.
Furthermore, it @emph{should} be possible to refer to a resource by a fully-qualified location on the web or an overlay network (e.g. tor).
@table @dfn
@item ERC165 Interface identifier
@include ../../build/Locator.interface
@item Solidity interface definition
@include ../../build/contract_Locator.texi
@item Example implementation
@uref{git://holbrook.no/eth-event-msg.git}
@end table
@subsubsection Expressing locators in terms of numetic token id
Given the numeric token id @code{1234567890987654321} (@code{0x112210f4b16c1cb1} hex), and a base url @code{https://contentgateway.grassecon.net}, the result of the methods may be as follows:
@table @code
@item toURI(toHex(1234567890987654321))
-> @code{https://contentgateway.grassecon.net/000000000000000000000000000000000000000000000000112210f4b16c1cb1}
@item toURL(toHex(1234567890987654321))
-> @code{https://contentgateway.grassecon.net/000000000000000000000000000000000000000000000000112210f4b16c1cb1}
@item tokenURI(1234567890987654321)
-> @code{https://contentgateway.grassecon.net/000000000000000000000000000000000000000000000000112210f4b16c1cb1}
@end table
@subsubsection Expressing locators in terms of a digest
Given the data @code{foo}, the digest algorithm @code{sha256} and a base url @code{https://contentgateway.grassecon.net}, the result of the methods may be as follows:
@table @code
@item toURI(sha256(foo))
-> @code{"sha256:2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae"}
@item toURL(sha256(foo))
-> @code{"https://contentgateway.grassecon.net/2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae"}
@item tokenURI(toUint(sha256(foo)))
-> @code{"https://contentgateway.grassecon.net/2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae"}
@end table
@subsubsection Locator without URL
Given the data @code{foo}, the digest algorithm @code{sha256} and no base url, the result of the methods may be as follows:
@table @code
@item toURI(sha256(foo))
-> @code{"sha256:2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae"}
@item toURL(sha256(foo))
-> @code{""}
@item tokenURI(toUint(sha256(foo)))
-> @code{"sha256:2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae"}
@end table

View File

@ -0,0 +1,14 @@
@subsection Minter
Attached to @code{ERC20} and @code{ERC721} tokens that may be minted.
Implements the @code{mint(...)} and @code{safeMint(...)} parts of @code{ERC5679} for interoperability.
@table @dfn
@item ERC165 Interface identifier
@include ../../build/Minter.interface
@item Solidity interface definition
@include ../../build/contract_Minter.texi
@item Example implementation
@uref{https://git.grassecon.net/cicnet/erc20-demurrage-token.git}
@end table

17
doc/texinfo/msg.sol.texi Normal file
View File

@ -0,0 +1,17 @@
@subsection Msg
Enables a reference "message" to describe the contract using an off-chain resource.
The reference may or may not be mutable.
The interface complements @code{Locator} and @code{MultiHash} to generate locators for how to resolve the reference.
@table @dfn
@item ERC165 Interface identifier
@include ../../build/Msg.interface
@item Solidity interface definition
@include ../../build/contract_Msg.texi
@item Example implementation
@uref{git://holbrook.no/eth-event-msg.git}
@end table

59
doc/texinfo/old.texi Normal file
View File

@ -0,0 +1,59 @@
@subsection Auxiliary contracts
All other Smart Contracts in the network other than CICRegistry are essentially optional, and each applies @emph{at least one} the interfaces defined in the @code{cic-contracts} repository.
@subsection Contract interfaces
All contracts interfaces also implement the @strong{EIP165} Standard Interface Detection.
@subsubsection Registry
A key-value store, which resolves arbitrary 32-byte pointers to Ethereum addresses. Typically, this is used to resolve an address from a well-known identifier, either as a UTF-8 value or a 256-bit hash.
It also provides numerical index access to all registered values in order of insertion.
@subsubsection Registry Client
A subset of the @code{Registry} interface, which defines only the non-transactional methods of the contract. The @code{Registry Client} interface is implemented by the @code{CICRegistry} contract.
@subsubsection Faucet
Enables disbursement of a set amount of tokens to a requesting address.
Allows privileged accounts to adjust the amount of tokens to disburse.
Can be implemented as a periodic or a one-time service per account.
@subsubsection Transfer approval
Enables a third-party approval to spend an ERC20 token allowance.
This is useful in the case of a custodial key store, where a transaction has been initiated by another entity than the owner of the key.
The contract allows the third-party address to either allow or reject the transfer.
@subsubsection Declarator
Stores one or more 32-byte entries as a description of an Ethereum address, @emph{signed} by another Ethereum address.
This can be used to @emph{describe} network resources, be it tokens, contracts or user accounts. Examples of uses are KYC documentation proofs for users, token metadata used for display, or fraud alerts.
Entries are stored by the transacting address that adds address/description pairs. In other words, any address may have different "opinions" registered about it, depending on which signing address it is queried in the context of. This, in turn, allows the quering entity to compile its own "opinion" of an address by combining data from signatures it trusts.
Entries typically are text strings or content hashes.
@subsubsection Address Index
A simple append-only list of addresses. Used to check whether an address is part of a particular group.
@subsubsection DEX Index
Methods required to convert between tokens.

View File

@ -2,75 +2,80 @@
@chapter Smart contract interfaces
@section Smart Contracts in the CIC Network
@subsection Technology
@section Technology
The long-term aim of the CIC network is to be agnostic of consensus engines. However, since we have to start @emph{somewhere}, the current state of development only deals with Smart Contracts on the (Ethereum Virtual Machine (EVM).
CIC smart contracts are implemented using the @emph{solidity} programming language for the (Ethereum Virtual Machine (EVM).
@subsection The registry contract
@section Adopted standards
The CICRegistry contract defines the entry-point to the entire CIC network. All other CIC network resources can be discovered through this contract.
Its implementation is contained in the @file{cic-registry} repository. Details about it are documented further in that section.
@subsection Auxiliary contracts
All other Smart Contracts in the network other than CICRegistry are essentially optional, and each applies @emph{at least one} the interfaces defined in the @code{cic-contracts} repository.
@subsection Signing
@subsection Contract interfaces
@subsection ERC - Direct use
All contracts interfaces also implement the @strong{EIP165} Standard Interface Detection.
The following well-known solidity interfaces are used directly.
@subsubsection Registry
A key-value store, which resolves arbitrary 32-byte pointers to Ethereum addresses. Typically, this is used to resolve an address from a well-known identifier, either as a UTF-8 value or a 256-bit hash.
It also provides numerical index access to all registered values in order of insertion.
@itemize @bullet
@item
@uref{https://eips.ethereum.org/EIPS/eip-20, ERC20 - Token Standard}
@item
@uref{https://eips.ethereum.org/EIPS/eip-165, ERC165 - Standard Interface Detection}
@item
@uref{https://eips.ethereum.org/EIPS/eip-173, ERC173 - Contract Ownership Standard}
@item
@uref{https://eips.ethereum.org/EIPS/eip-191, ERC191 - Signed Data Standard}
@item
@uref{https://eips.ethereum.org/EIPS/eip-712, ERC712 - Typed structured data hashing and signing}
@item
@uref{https://eips.ethereum.org/EIPS/eip-721, ERC721 - Non-Fungible Token Standard}
@item
@uref{https://eips.ethereum.org/EIPS/eip-5007, ERC5007 - Time NFT (EIP-721 Time Extension)}
@item
@uref{https://eips.ethereum.org/EIPS/eip-5192, ERC5192 - Minimal Soulbound NFTs}
@end itemize
@subsubsection Registry Client
@subsection ERCs Partial use
A subset of the @code{Registry} interface, which defines only the non-transactional methods of the contract. The @code{Registry Client} interface is implemented by the @code{CICRegistry} contract.
The following well-known solidity interfaces are partially implemented in CIC native interfaces.
@itemize @dfn
@item
@uref{https://eips.ethereum.org/EIPS/eip-5679, ERC5679 - Token Minting and Burning} (See @code{Minter}, @code{Burner})
@end itemize
@subsubsection Faucet
@section Native interfaces
Enables disbursement of a set amount of tokens to a requesting address.
@include accountsindex.sol.texi
Allows privileged accounts to adjust the amount of tokens to disburse.
@include burner.sol.texi
Can be implemented as a periodic or a one-time service per account.
@include chrono.sol.texi
@include declarator.sol.texi
@subsubsection Transfer approval
@include digest.sol.texi
Enables a third-party approval to spend an ERC20 token allowance.
@include expire.sol.texi
This is useful in the case of a custodial key store, where a transaction has been initiated by another entity than the owner of the key.
@include faucet.sol.texi
The contract allows the third-party address to either allow or reject the transfer.
@include locator.sol.texi
@include minter.sol.texi
@subsubsection Declarator
@include msg.sol.texi
Stores one or more 32-byte entries as a description of an Ethereum address, @emph{signed} by another Ethereum address.
@include registry.sol.texi
This can be used to @emph{describe} network resources, be it tokens, contracts or user accounts. Examples of uses are KYC documentation proofs for users, token metadata used for display, or fraud alerts.
@include seal.sol.texi
Entries are stored by the transacting address that adds address/description pairs. In other words, any address may have different "opinions" registered about it, depending on which signing address it is queried in the context of. This, in turn, allows the quering entity to compile its own "opinion" of an address by combining data from signatures it trusts.
@include tokenvend.sol.texi
Entries typically are text strings or content hashes.
@include tokenvote.sol.texi
@subsubsection Address Index
A simple append-only list of addresses. Used to check whether an address is part of a particular group.
@subsubsection DEX Index
Methods required to convert between tokens.
@include writer.sol.texi

View File

@ -0,0 +1,23 @@
@subsection Registry
The Registry interface is a key-value store resolving well-known contract identifier names to contract addresses.
It currently has two distinct uses in the CIC context:
@enumerate
@item
Entry-point to discover all relevant contracts of CIC networks.
@item
Unique (ERC20) token symbol resolver.
@end enumerate
@table @dfn
@item ERC165 Interface identifier
@include ../../build/RegistryClient.interface
@item Solidity interface definition
@include ../../build/contract_RegistryClient.texi
@item Contract registry implementation
@uref{git://holbrook.no/eth-contract-registry.git,}
@item Token index implementation
@uref{git://holbrook.no/eth-contract-registry.git,}
@end table

31
doc/texinfo/seal.sol.texi Normal file
View File

@ -0,0 +1,31 @@
@subsection Seal
Some smart contract parameters may need to be mutable over part of a smart contract's lifetime.
This interface provides a method to explicitly signal when certain parameters have been rendered immutable.
The value of @code{sealState()} @emph{must not} decrease, and must not exceed @code{maxSealState}.
@code{maxSealState} is used to define that @emph{all mutable parameters} have been rendered immutable. The practical implications of this will vary between contracts.
The implementer is encouraged to use simple, descriptive names in the source code to describe the applicable seal states.
Use cases of sealing include:
@itemize
@item
Whether more tokens can be minted
@item
Allow ownership of a contract to be transferred
@item
The expiry time of a token (see @code{Expire})
@end itemize
@table @dfn
@item ERC165 Interface identifier
@include ../../build/Seal.interface
@item Solidity interface definition
@include ../../build/contract_Seal.texi
@item Example implementation
@uref{https://git.grassecon.net/cicnet/erc20-demurrage-token.git}
@end table

View File

@ -0,0 +1,21 @@
@subsection TokenVend
This interface defines the mechanism for which a specific ERC20 token may be exchanged for a different ERC20 token.
A typical use-case is generation of voting tokens based on a momentary voucher balance. This is especially useful if the original ERC20 token is subject to decay (demurrage).
The tokens used for exchange @strong{SHOULD} be locked for the full duration of holding the vended tokens.
The withdrawal function may or may not allow partial withdrawals.
@table @dfn
@item ERC165 Interface identifier
@include ../../build/TokenVend.interface
@item Solidity interface definition
@include ../../build/contract_TokenVend.texi
@item Reference implementations
@itemize
@item
@uref{git://holbrook.no/erc20-vend.git,}
@end itemize
@end table

View File

@ -0,0 +1,23 @@
@anchor{token_vote}
@subsection TokenVote
Execute elections with granular ERC20 token votes.
A proposal submitted for vote may or may not contain multiple options. If multiple options are available, an ERC20 token holder may distribute its vote among the options with the granularity of the token balance.
Voted tokens @strong{SHOULD} be locked until the voting has finalized.
Finalization of voting should be callable by anyone.
@table @dfn
@item ERC165 Interface identifier
@include ../../build/TokenVote.interface
@item Solidity interface definition
@include ../../build/contract_TokenVote.texi
@item Reference implementations
@itemize
@item
@uref{git://holbrook.no/evm-tokenvote.git,}
@end itemize
@end table

View File

@ -0,0 +1,29 @@
@subsection Writer
A complement to ERC173, which allows definition of a class of super-users for a contract.
A super-user address may perform @emph{more} actions than a "normal" address, aswell as @emph{some} actions normally limited to the @emph{contract owner}.
If an @emph{contract owner} is defined, No super-user should be able to perform actions that @emph{contract owner} cannot perform.
Typically, only the @emph{contract owner}, if it is defined, can add or remove a super-user.
Some use-case examples of super-user actions include:
@itemize
@item
Mint new tokens.
@item
Change the amount dispensed by the faucet.
@item
Edit access control lists.
@end itemize
@table @dfn
@item ERC165 Interface identifier
@include ../../build/Writer.interface
@item Solidity interface definition
@include ../../build/contract_Writer.texi
@item Example implementation
@uref{https://git.grassecon.net/cicnet/erc20-demurrage-token.git}
@end table

View File

@ -1 +1 @@
chainlib-eth>=0.3.0,<0.4.0
chainlib-eth~=0.4.7

View File

@ -1,18 +1,28 @@
pragma solidity >=0.6.12;
// Author: Louis Holbrook <dev@holbrook.no> 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
// SPDX-License-Identifier: GPL-3.0-or-later
// File-version: 3
// SPDX-License-Identifier: AGPL-3.0-or-later
// File-version: 6
interface AddressIndex {
event AddressAdded(address indexed addedAccount, uint256 indexed accountIndex); // AccountsIndex
interface IAccountsIndex {
// Address added to store, index in array.
event AddressAdded(uint256 indexed _idx, address _account);
// Return number of entries in index
// Return number of entries in index.
function entryCount() external view returns (uint256);
// Return entry at the spceificed index
// Return entry at the spceificed index.
// Will revert if index is beyond array length.
// An entry result of 0 means the entry should be skipped, and not count towards entry count.
function entry(uint256) external view returns (address);
// Add an entry to the index
function add(address _account) external returns (bool);
// Verify that the entry exists in the index
function have(address _account) external view returns (bool);
// Add an entry to the index. Incresases the entry count.
function add(address) external returns (bool);
// Verify that the entry exists in the index.
function have(address) external view returns (bool);
// Retrieve the timestamp when account was added.
// If time is not being tracked, a value of 0 should be returned.
function time(address) external view returns (uint256);
}

View File

@ -0,0 +1,27 @@
pragma solidity >=0.6.12;
// Author: Louis Holbrook <dev@holbrook.no> 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
// SPDX-License-Identifier: AGPL-3.0-or-later
// File-version: 1
// Extends the AccountsIndex contract to enable account removal and deactivation.
interface IAccountsIndexMutable {
// Active status of address changed, and by whom changed.
event AddressActive(address indexed _account, bool _active);
// Address removed from store, and by whom removed.
event AddressRemoved(address _account);
// Remove an entry from the index. Reduces the entry count.
function remove(address) external returns (bool);
// Deactivate account but keep in index. Does not affect entry count.
function deactivate(address) external returns (bool);
// Activate previously deactivated account. Does not affect entry count.
function activate(address) external returns (bool);
// Check if account exists and is active;
function isActive(address) external view returns (bool);
}

26
solidity/Burner.sol Normal file
View File

@ -0,0 +1,26 @@
pragma solidity >=0.6.12;
// Author: Louis Holbrook <dev@holbrook.no> 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
// SPDX-License-Identifier: AGPL-3.0-or-later
// File-version: 3
interface IBurner {
// Token(s) successfully burned; by who and how much.
event Burn(address indexed _burner, uint256 _burned);
// Satisfies ERC 5679
function burn(address _from, uint256 _amount, bytes calldata _data) external;
// Burn given amount of tokens held by signer.
function burn(uint256 _burn) external returns (bool);
// Burn all tokens held by signer.
function burn() external returns (bool);
// Total amount of tokens that have been burned.
function totalBurned() external returns (uint256);
// Total amount of tokens ever minted.
// If totalSupply() is available (ERC20, ERC721 Enumerable), this equals totalSupply() + totalBurned().
function totalMinted() external returns (uint256);
}

11
solidity/Chrono.sol Normal file
View File

@ -0,0 +1,11 @@
pragma solidity >=0.6.12;
// Author: Louis Holbrook <dev@holbrook.no> 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
// SPDX-License-Identifier: AGPL-3.0-or-later
// File-version: 1
interface IChrono {
// Returns the timestamp of when a resource corresponding to _idx was first created.
// int64 chosen as return value for simpler interoperability with ERC5007.
function createTime(uint256 _idx) external returns(int64);
}

View File

@ -1,22 +1,33 @@
pragma solidity >=0.6.12;
// Author: Louis Holbrook <dev@holbrook.no> 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
// SPDX-License-Identifier: GPL-3.0-or-later
// File-version: 2
// SPDX-License-Identifier: AGPL-3.0-or-later
// File-version: 3
interface Declarator {
event DeclarationAdded(address _declarator, address _subject, bytes32 _proof);
interface IDeclarator {
event DeclarationAdded(address indexed _declarator, address indexed _subject, bytes32 indexed _topic, bytes32 _proof);
// Get all declarations for a subject signed by a declarator
// Get all declarations for a subject (without topic) signed by a declarator
function declaration(address _declarator, address _subject) external view returns ( bytes32[] memory );
// Get all declarations for a subject for the given topic signed by a declarator
function declaration(address _declarator, address _subject, bytes32 _topic) external view returns ( bytes32[] memory );
// Get number of declarations the declarator has ever signed
function declarationCount(address _declarator) external view returns ( uint256 );
// Get the subject of a declarator's declarations at the specific index
function declarationAddressAt(address _declarator, uint256 _idx) external view returns ( address );
// Add a declaration for the subject
function addDeclaration(address _subject, bytes32 _proof) external returns ( bool );
// Add a declaration with topic for the subject
function addDeclaration(address _subject, bytes32 _proof, bytes32 _topic) external returns ( bool );
// Get the declarator that signed a declaration at the specificed index for a subject
function declaratorAddressAt(address _subject, uint256 _idx) external view returns ( address );
// Get the number of declarators that have signed for a subject
function declaratorCount(address _subject) external view returns ( uint256 );
}

23
solidity/Digest.sol Normal file
View File

@ -0,0 +1,23 @@
pragma solidity >=0.6.12;
// Author: Louis Holbrook <dev@holbrook.no> 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
// SPDX-License-Identifier: AGPL-3.0-or-later
// File-version: 1
interface IDigest {
// Returns the default digest encoding used by the contract instance.
function defaultDigestEncoding() external view returns (uint256 _encoding);
// Check if the given encoding has been implemented in the contract instance.
function haveDigestEncoding(uint256 _codec) external view returns(bool);
// Verify and encode the given digest for a specific hashing algorithm.
// Returns a zero-length byte array if digest is invalid.
// Must succeed if called with the defaultDigestEncoding and a valid digest.
function encodeDigest(bytes memory _data, uint256 _encoding) external view returns (bytes memory);
// Encodes the digest using the default digest encoding.
// Returns a zero-length byte array if digest is invalid.
// Must succeed with a valid digest.
function encodeDigest(bytes memory _data) external view returns (bytes memory);
}

View File

@ -1,13 +1,12 @@
pragma solidity ^0.8.0;
pragma solidity >=0.6.12;
// Author: Louis Holbrook <dev@holbrook.no> 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
// SPDX-License-Identifier: GPL-3.0-or-later
// File-version: 2
// SPDX-License-Identifier: AGPL-3.0-or-later
// File-version: 4
// This is a representation of an officially approved Ethereum Improvement Proposal, written by Christian Reitwießner chris@ethereum.org, Nick Johnson nick@ethereum.org, Fabian Vogelsteller fabian@lukso.network, Jordi Baylina jordi@baylina.cat, Konrad Feldmeier konrad.feldmeier@brainbot.com and William Entriken github.com@phor.net. It was released under the CC0 license.
// The proposal source used as reference was a Markdown file with the following digests:
// - sha256:2fc8534206e1e5b7abbb9db21fa5b83d39c51b2dabad441a356b7d18320bfc51
// - swarmhash:a1a2860be878a818a9207503fbbe49cdbd86c3e02a4fdac0a4faafa78f6bdd80
interface ERC165 {
interface IERC165 {
function supportsInterface(bytes4 _sum) external pure returns (bool);
}

View File

@ -1,15 +1,15 @@
pragma solidity ^0.8.0;
pragma solidity >=0.6.12;
// Author: Louis Holbrook <dev@holbrook.no> 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
// SPDX-License-Identifier: GPL-3.0-or-later
// File-version: 2
// SPDX-License-Identifier: AGPL-3.0-or-later
// File-version: 3
// This is a representation of an officially approved Ethereum Improvement Proposal, written by Nick Mudge <nick@perfectabstractions.com> and Dan Finlay <dan@danfinlay.com> and released under the CC0 license.
// The proposal source used as reference was a Markdown file with the following digests:
// - sha256:45e14ac315e380b5372a5ffc6783ab11d7eafb7fa5a123e0b8e5fc8c6c527c4c
// - swarmhash:0cadf6a7122d2da20dbab0ef31c692b1b24cf49ae5c1c80f7ce6dbae8885ce01
interface ERC173 {
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); // EIP173
interface IERC173 {
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
function owner() external view returns (address);
function transferOwnership(address _newOwner) external view returns (bool);

View File

@ -1,16 +1,15 @@
pragma solidity >=0.6.12;
// Author: Louis Holbrook <dev@holbrook.no> 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
// SPDX-License-Identifier: GPL-3.0-or-later
// File-version: 1
// SPDX-License-Identifier: AGPL-3.0-or-later
// File-version: 3
// This is a representation of an officially approved Ethereum Improvement Proposal, written by Fabian Vogelsteller fabian@ethereum.org, Vitalik Buterin vitalik.buterin@ethereum.org. It was released under the CC0 license.
// The proposal source used as reference was a Markdown file with the following digests:
// - sha256:d120f321f2bef19596a401fba86d13352693ccd39645c2bbc84ffb3ed551388f
// - swarmhash:598f13429ec42f50d7a6576ab20feffdaf2135a90805678d24e4ea297bf0e639
interface ERC20 {
interface IERC20 {
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event TransferFrom(address indexed _from, address indexed _to, address indexed _spender, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
function transfer(address _to, uint256 _value) external returns (bool);

15
solidity/ERC5007.sol Normal file
View File

@ -0,0 +1,15 @@
pragma solidity >=0.6.12;
// Author: Louis Holbrook <dev@holbrook.no> 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
// SPDX-License-Identifier: AGPL-3.0-or-later
// File-version: 4
// This is a representation of an officially approved Ethereum Improvement Proposal, written by Anders (@0xanders), Lance (@LanceSnow), Shrug <shrug@emojidao.org>.
// It was released under the CC0 license.
// The proposal source used as reference was a Markdown file with the following digest:
// - sha256:ec5a3d25822e616e032ef27faeb9a7191147a7b18064d95807df20fbc6b69870
interface IERC5007 {
function startTime(uint256 tokenId) external view returns (int64);
function endTime(uint256 tokenId) external view returns (int64);
}

17
solidity/ERC5192.sol Normal file
View File

@ -0,0 +1,17 @@
pragma solidity >=0.6.12;
// Author: Louis Holbrook <dev@holbrook.no> 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
// SPDX-License-Identifier: AGPL-3.0-or-later
// File-version: 4
// This is a representation of an officially approved Ethereum Improvement Proposal, written by Tim Daubenschütz (@TimDaub), Anders (@0xanders).
// It was released under the CC0 license.
// The proposal source used as reference was a Markdown file with the following digest:
// - sha256:c746922587ede699bd1560be0c0db5599104a25c976077d20706ec05340b3b7a
interface IERC5192 {
event Locked(uint256 tokenId);
event Unlocked(uint256 tokenId);
function locked(uint256 tokenId) external view returns (bool);
}

14
solidity/ERC5679Ext20.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
// This is a representation of an officially approved Ethereum Improvement Proposal, Zainan Victor Zhou (@xinbenlv).
// The proposal source used as reference was a Markdown file with the following digests:
// - sha256:7e799dd22588f62c52c4886d7b523c12696441a6c2350b739562ea8fb5d60649
interface IERC5679Ext20 {
function mint(address _to, uint256 _amount, bytes calldata _data) external;
function burn(address _from, uint256 _amount, bytes calldata _data) external;
}

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: 2
// This is a representation of an officially approved Ethereum Improvement Proposal, Zainan Victor Zhou (@xinbenlv).
// The proposal source used as reference was a Markdown file with the following digests:
// - sha256:7e799dd22588f62c52c4886d7b523c12696441a6c2350b739562ea8fb5d60649
interface IERC5679Ext721 {
function safeMint(address _to, uint256 _id, bytes calldata _data) external;
function burn(address _from, uint256 _id, bytes calldata _data) external;
}

View File

@ -1,21 +1,22 @@
pragma solidity >=0.6.12;
// Author: Louis Holbrook <dev@holbrook.no> 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
// SPDX-License-Identifier: GPL-3.0-or-later
// File-version: 1
// SPDX-License-Identifier: AGPL-3.0-or-later
// File-version: 3
// This is a representation of an officially approved Ethereum Improvement Proposal, William Entriken (@fulldecent), Dieter Shirley dete@axiomzen.co, Jacob Evans jacob@dekz.net, Nastassia Sachs nastassia.sachs@protonmail.com
// The proposal source used as reference was a Markdown file with the following digests:
// - sha256:f25b41ad1bff14ec57e8c247f2ecf372fd86245d08ba3cbd005c21a42744a7ca
// - swarmhash:cf43d96b21b0b017ae32fb2ac8df9268f13344d9fd20aa1d959453eaf379a51b
interface ERC721 {
interface IERC721 {
event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId);
event Approval(address indexed _owner, address indexed _approved, uint256 indexed _tokenId);
event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved);
function balanceOf(address _owner) external view returns (uint256);
function ownerOf(uint256 _tokenId) external view returns (address);
function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes memory data) external payable;
function safeTransferFrom(address _from, address _to, uint256 _tokenId) external payable;
function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes memory _data) external payable;
function transferFrom(address _from, address _to, uint256 _tokenId) external payable;
function approve(address _approved, uint256 _tokenId) external payable;
function setApprovalForAll(address _operator, bool _approved) external;

View File

@ -1,14 +1,14 @@
pragma solidity >=0.6.12;
// Author: Louis Holbrook <dev@holbrook.no> 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
// SPDX-License-Identifier: GPL-3.0-or-later
// File-version: 1
// SPDX-License-Identifier: AGPL-3.0-or-later
// File-version: 2
// This is a representation of an officially approved Ethereum Improvement Proposal, William Entriken (@fulldecent), Dieter Shirley dete@axiomzen.co, Jacob Evans jacob@dekz.net, Nastassia Sachs nastassia.sachs@protonmail.com
// The proposal source used as reference was a Markdown file with the following digests:
// - sha256:f25b41ad1bff14ec57e8c247f2ecf372fd86245d08ba3cbd005c21a42744a7ca
// - swarmhash:cf43d96b21b0b017ae32fb2ac8df9268f13344d9fd20aa1d959453eaf379a51b
interface ERC721Enumerable {
interface IERC721Enumerable {
function totalSupply() external view returns (uint256);
function tokenByIndex(uint256 _index) external view returns (uint256);
function tokenOfOwnerByIndex(address _owner, uint256 _index) external view returns (uint256);

View File

@ -1,14 +1,14 @@
pragma solidity >=0.6.12;
// Author: Louis Holbrook <dev@holbrook.no> 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
// SPDX-License-Identifier: GPL-3.0-or-later
// File-version: 1
// SPDX-License-Identifier: AGPL-3.0-or-later
// File-version: 2
// This is a representation of an officially approved Ethereum Improvement Proposal, William Entriken (@fulldecent), Dieter Shirley dete@axiomzen.co, Jacob Evans jacob@dekz.net, Nastassia Sachs nastassia.sachs@protonmail.com
// The proposal source used as reference was a Markdown file with the following digests:
// - sha256:f25b41ad1bff14ec57e8c247f2ecf372fd86245d08ba3cbd005c21a42744a7ca
// - swarmhash:cf43d96b21b0b017ae32fb2ac8df9268f13344d9fd20aa1d959453eaf379a51b
interface ERC721Metadata {
interface IERC721Metadata {
function name() external view returns (string memory _name);
function symbol() external view returns (string memory _symbol);
function tokenURI(uint256 _tokenId) external view returns (string memory);

View File

@ -1,13 +1,13 @@
pragma solidity >=0.6.12;
// Author: Louis Holbrook <dev@holbrook.no> 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
// SPDX-License-Identifier: GPL-3.0-or-later
// File-version: 1
// SPDX-License-Identifier: AGPL-3.0-or-later
// File-version: 2
// This is a representation of an officially approved Ethereum Improvement Proposal, William Entriken (@fulldecent), Dieter Shirley dete@axiomzen.co, Jacob Evans jacob@dekz.net, Nastassia Sachs nastassia.sachs@protonmail.com
// The proposal source used as reference was a Markdown file with the following digests:
// - sha256:f25b41ad1bff14ec57e8c247f2ecf372fd86245d08ba3cbd005c21a42744a7ca
// - swarmhash:cf43d96b21b0b017ae32fb2ac8df9268f13344d9fd20aa1d959453eaf379a51b
interface ERC721Receiver {
interface IERC721Receiver {
function onERC721Received(address _operator, address _from, uint256 _tokenId, bytes memory _data) external returns(bytes4);
}

23
solidity/Expire.sol Normal file
View File

@ -0,0 +1,23 @@
pragma solidity >=0.6.12;
// Author: Louis Holbrook <dev@holbrook.no> 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
// SPDX-License-Identifier: AGPL-3.0-or-later
// File-version: 3
interface IExpire {
// Contract has expired.
event Expired(uint256 _timestamp);
// Expiry time has changed.
event ExpiryChange(uint256 indexed _oldTimestamp, uint256 _newTimestamp);
// The current expiration timestamp.
function expires() external returns (uint256);
// Check expiry and apply expiration if expired.
// Return values must be:
// 0: not yet expired.
// 1: already expired.
// >1: expiry executed.
function applyExpiry() external returns(uint8);
}

View File

@ -1,23 +1,39 @@
pragma solidity >=0.6.12;
// Author: Louis Holbrook <dev@holbrook.no> 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
// SPDX-License-Identifier: GPL-3.0-or-later
// File-version: 5
// SPDX-License-Identifier: AGPL-3.0-or-later
// File-version: 6
interface Faucet {
event FaucetUsed(address indexed _recipient, address indexed _token, uint256 _value);
event FaucetFail(address indexed _recipient, address indexed _token, uint256 _value);
interface IFaucet {
// Tokens were given to an address
event Give(address indexed _recipient, address indexed _token, uint256 _value);
// The amount that the faucet disperses has changed
event FaucetAmountChange(uint256 _value);
// Address of token the faucet represents
// The faucet will return gas tokens with the zero-address is returned.
function token() external returns (address);
// Amount of tokens the faucet gives out
function tokenAmount() external returns (uint256);
// Set the amount of tokens that the faucet gives out
function setAmount(uint256 _amount) external returns (bool);
// Give tokens to the given recipient
function giveTo(address _recipient) external returns (bool);
// Number of blocks that must be mined until faucet can be used for the same address
// max uint (-1) can be used to indicate that faucet may not be reused
function cooldown(address _recipient) external returns (uint256);
// Give tokens to the given recipient. Returns amount of tokens given.
function giveTo(address _recipient) external returns (uint256);
// Give tokens to yourself. Returns amount of tokens given.
function gimme() external returns (uint256);
// Check if faucet may be used in the current contract state by _recipient
function check(address _recipient) external view returns (bool);
// Returns timestamp when faucet may be used again by _recipient
// If 0 is returned, the address has not yet been used.
// A return value of max(uint256) indicates that the faucet may not be used again.
function nextTime(address _recipient) external returns (uint256);
// Returns the token balance under which faucet may be used again by _recipient
// A return value of max(uint256) indicates that the faucet may be used regardless
// of the token balance of _recipient
function nextBalance(address _recipient) external returns (uint256);
}

13
solidity/Locator.sol Normal file
View File

@ -0,0 +1,13 @@
pragma solidity >=0.6.12;
// Author: Louis Holbrook <dev@holbrook.no> 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
// SPDX-License-Identifier: AGPL-3.0-or-later
// File-version: 4
interface ILocator {
// URI that may or may not point to a specific resource location.
function toURI(bytes memory _data) external view returns (string memory);
// URL pointing to a specific resource location.
function toURL(bytes memory _data) external view returns(string memory);
}

View File

@ -1,12 +1,19 @@
pragma solidity >=0.6.12;
// Author: Louis Holbrook <dev@holbrook.no> 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
// SPDX-License-Identifier: GPL-3.0-or-later
// File-version: 1
// SPDX-License-Identifier: AGPL-3.0-or-later
// File-version: 2
interface Minter {
interface IMinter {
// Tokens are successfully minted; by who, to whom and how much
event Mint(address indexed _minter, address indexed _beneficiary, uint256 value);
// Mint the specified value of tokens to the specified recipient
function mintTo(address _beneficiary, uint256 value) external returns (bool);
// Satisfies ERC5679 for ERC20
function mint(address _beneficiary, uint256 value, bytes calldata _data) external;
// Satisfies ERC5679 for ERC721
function safeMint(address _beneficiary, uint256 value, bytes calldata _data) external;
}

14
solidity/Msg.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: 2
interface IMsg {
// Emitted when a new message digest has been set
// Should not be emitted if the digest set is identical to the previous
event Msg(bytes _msgDigest);
// Get the current message content hash
function getMsg() external view returns(bytes memory);
}

24
solidity/MultiHash.sol Normal file
View File

@ -0,0 +1,24 @@
pragma solidity >=0.6.12;
// Author: Louis Holbrook <dev@holbrook.no> 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
// SPDX-License-Identifier: AGPL-3.0-or-later
// File-version: 2
interface IMultiHash {
// Represents a multicodec item.
struct MultiHash {
uint8 l;
uint8 codecRLength;
uint8 prefixRLength;
bytes16 prefix;
bytes8 codec;
}
// All registered multicodecs
function digestCodec(uint256 _codec) external view returns(MultiHash memory);
function haveDigestEncoding(uint256 _codec) external view returns(bool);
// Generate a multihash from the given digest and current selected multicodec
function encodeDigest(uint256 _codec, bytes memory _digest) external view returns(bytes memory);
}

23
solidity/Offline.sol Normal file
View File

@ -0,0 +1,23 @@
pragma solidity >=0.6.12;
// Author: Louis Holbrook <dev@holbrook.no> 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
// SPDX-License-Identifier: AGPL-3.0-or-later
// File-version: 1
interface IOffline {
// Verify signer and data
// Check input assuming signature is valid against contract instance.
function isOfflineValid(address _signer, bytes memory _data) external view returns(bool);
// Verify signature against data, and isOfflineValid() against data and signer (as validator)
// Signature must be ERC191 version 0x00 with contract instance as validator.
function verifyOfflineRequest(bytes memory _data, bytes memory _signature) external view returns(bool);
// Change state if signature and signer is valid.
// Call verifyOfflineRequest and:
// - revert if it returns false.
// - return 0 if state is changed according to the request.
// - return any other valid to indicate an application specific error.
function executeOfflineRequest(bytes memory _data, bytes memory _signature) external returns(uint256);
}

View File

@ -1,9 +1,9 @@
pragma solidity ^0.8.0;
pragma solidity >=0.6.12;
// Author: Louis Holbrook <dev@holbrook.no> 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
// SPDX-License-Identifier: GPL-3.0-or-later
// File-version: 1
// SPDX-License-Identifier: AGPL-3.0-or-later
// File-version: 2
interface OwnerAcceptable {
interface IOwnerAcceptable {
function acceptOwnership() external view returns (bool);
}

View File

@ -1,8 +1,8 @@
pragma solidity ^0.8.0;
pragma solidity >=0.6.12;
// Author: Louis Holbrook <dev@holbrook.no> 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
// SPDX-License-Identifier: GPL-3.0-or-later
// File-version: 1
// SPDX-License-Identifier: AGPL-3.0-or-later
// File-version: 2
interface OwnerTakeable {
event OwnershipTaken(address _result);

View File

@ -1,11 +1,10 @@
pragma solidity >=0.6.12;
// Author: Louis Holbrook <dev@holbrook.no> 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
// SPDX-License-Identifier: GPL-3.0-or-later
// File-version: 1
// SPDX-License-Identifier: AGPL-3.0-or-later
// File-version: 3
interface Registry {
interface IRegistry {
function set(bytes32, address) external returns (bool);
function bind(bytes32, bytes32) external returns (bool);
function identifiers(uint256) external view returns (bytes32);
}

View File

@ -1,9 +1,19 @@
pragma solidity >=0.6.12;
// Author: Louis Holbrook <dev@holbrook.no> 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-License-Identifier: AGPL-3.0-or-later
// File-version: 3
interface RegistryClient {
interface IRegistryClient {
// Address added to store with the given key
event AddressKey(bytes32 indexed _key, address _address);
// Return the address of the contract identified by the given byte string
function addressOf(bytes32) external view returns (address);
// Indexed accessor for the full list of registred identifiers
function identifier(uint256) external view returns (bytes32);
// Number of registered interfaces
function identifierCount() external view returns (uint256);
}

16
solidity/Seal.sol Normal file
View File

@ -0,0 +1,16 @@
pragma solidity >=0.6.12;
// Author: Louis Holbrook <dev@holbrook.no> 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
// SPDX-License-Identifier: AGPL-3.0-or-later
// File-version: 1
interface ISeal {
// Seal state has changed.
event SealStateChange(bool indexed _final, uint256 _sealState);
// The current seal state.
function sealState() external view returns(uint256);
// The numeric seal state in everything sealable has been sealed.
function maxSealState() external view returns(uint256);
}

16
solidity/TokenVend.sol Normal file
View File

@ -0,0 +1,16 @@
pragma solidity >=0.6.12;
// Author: Louis Holbrook <dev@holbrook.no> 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
// SPDX-License-Identifier: AGPL-3.0-or-later
// File-version: 1
interface ITokenVend {
// A new vended token has been created.
event TokenCreated(uint256 indexed _tokenIdx, uint256 indexed _supply, address _token);
// Create corresponding vended tokens for the control token balance of the caller.
function getFor(address _token) external returns (uint256);
// Recover control tokens that were used to retrieve the corresponding vended tokens.
function withdrawFor(address _token) external returns (uint256);
}

56
solidity/TokenVote.sol Normal file
View File

@ -0,0 +1,56 @@
pragma solidity >=0.6.12;
// Author: Louis Holbrook <dev@holbrook.no> 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
// SPDX-License-Identifier: AGPL-3.0-or-later
// File-version: 1
interface ITokenVote {
// A new proposal has been created.
event ProposalAdded(uint256 indexed _blockDeadline, uint256 indexed voteTargetPpm, uint256 indexed _proposalIdx);
// A proposal vote has been completed.
// The proposal is identified by the serial number in _proposalIdx. It is up to the implementer to define how the proposal should be retrieved by index.
// The proposal result may be in one of three states:
// * Ratified (_cancelled == false, _insufficient == false)
// * Cancelled (_cancelled == true, _insufficient == false)
// * Not reached quorum (_cancelled == false, _insufficient == true)
event ProposalCompleted(uint256 indexed _proposalIdx, bool indexed _cancelled, bool indexed _insufficient, uint256 _totalVote);
// Propose a new vote.
// Voting is active until one of:
// * total cancel vote reach quorum (_targetVotePpm, ppm = parts-per-million).
// * _blockWait blocks from now.
function propose(bytes32 _description, uint256 _blockWait, uint24 _targetVotePpm) external returns (uint256);
// Same as propose(...), but provide options to vote on.
function proposeMulti(bytes32 _description, bytes32[] memory _options, uint256 _blockWait, uint24 _targetVotePpm) external returns (uint256);
// Get proposal option. Assumes that proposal was created with proposeMulti(...)
function getOption(uint256 _proposalIdx, uint256 _optionIdx) external view returns (bytes32);
// Get vote count for the given option.
// If proposal has no options, it should be called with _optionIdx = 0
function voteCount(uint256 _proposalIdx, uint256 _optionIdx) external view returns(uint256);
// Vote on a proposal without options.
// Assumes that proposal was created with propose(...) and will fail otherwise.
function vote(uint256 _value) external returns (bool);
// Vote on a proposal option. Assumes that proposal was created with proposeMulti(...).
// Must work with a non-option proposal if _optionIndex is 0.
function voteOption(uint256 _optionIndex, uint256 _value) external returns (bool);
// Vote to cancel a proposal.
// If cancel has the majority:
// * A vote without options will have rejected the proposal description.
// * A vote with options will have rejected the proposal description as well as all option descriptions.
function voteCancel(uint256 _value) external returns (bool);
// Finalize the vote for a proposal.
// May be called if deadline has been passed, or if:
// * quorum has been reached with cancel votes.
// * quorum has been reached and proposal has no/only one option.
function finalize() external returns (bool);
}

View File

@ -1,10 +1,22 @@
pragma solidity >=0.6.12;
// Author: Louis Holbrook <dev@holbrook.no> 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
// SPDX-License-Identifier: GPL-3.0-or-later
// File-version: 1
// SPDX-License-Identifier: AGPL-3.0-or-later
// File-version: 4
interface Writer {
interface IWriter {
// A writer has been added by _executor
event WriterAdded(address _writer);
// A writer has been removed by _executor
event WriterDeleted(address _writer);
// Add a new writer to the contract.
function addWriter(address _writer) external returns (bool);
// Remove existing writer from the contract.
function deleteWriter(address _writer) external returns (bool);
// Check whether the given address is a writer.
function isWriter(address _writer) external returns (bool);
}

10
texify.sh Normal file
View File

@ -0,0 +1,10 @@
#!/bin/bash
for f in $(ls solidity/*.sol); do
fn=$(basename $f)
fb=${fn%.*}
fn="build/contract_${fb}.texi"
echo "@verbatim" > $fn
awk 'f;/interface [a-zA-Z0-9]* /{print;f=1}' $f >> $fn
echo "@end verbatim" >> $fn
done