Add Digest interface
This commit is contained in:
parent
1e11d8df08
commit
b3f6e45696
15
doc/texinfo/chrono.sol.texi
Normal file
15
doc/texinfo/chrono.sol.texi
Normal 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
|
17
doc/texinfo/digest.sol.texi
Normal file
17
doc/texinfo/digest.sol.texi
Normal 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
|
@ -10,4 +10,6 @@ A contract defining an expiry @emph{must not} allow changing the expiration time
|
||||
@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
|
||||
|
@ -13,6 +13,8 @@ Furthermore, it @emph{should} be possible to refer to a resource by a fully-qua
|
||||
@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
|
||||
|
||||
|
||||
|
@ -12,4 +12,6 @@ The interface complements @code{Locator} and @code{MultiHash} to generate locat
|
||||
@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
|
||||
|
@ -1,25 +0,0 @@
|
||||
@subsection Multihash
|
||||
|
||||
A complement to @code{Locator}, enabling validation and generation of multihashes for multicodecs that have been registered to the contract.
|
||||
|
||||
|
||||
@table @dfn
|
||||
@item ERC165 Interface identifier
|
||||
@include ../../build/MultiHash.interface
|
||||
@item Solidity interface definition
|
||||
@include ../../build/contract_MultiHash.texi
|
||||
@end table
|
||||
|
||||
|
||||
@subsubsection Using @code{Multihash} with @code{Locator}
|
||||
|
||||
Given the data @code{foo}, the digest algorithm @code{sha256} (multihash prefix @code{1220}) 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/12202c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae"}
|
||||
@item tokenURI(toUint(sha256(foo)))
|
||||
-> @code{"https://contentgateway.grassecon.net/12202c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae"}
|
||||
@end table
|
@ -50,6 +50,8 @@ The following well-known solidity interfaces are partially implemented in CIC na
|
||||
|
||||
@include declarator.sol.texi
|
||||
|
||||
@include digest.sol.texi
|
||||
|
||||
@include expire.sol.texi
|
||||
|
||||
@include faucet.sol.texi
|
||||
@ -60,8 +62,6 @@ The following well-known solidity interfaces are partially implemented in CIC na
|
||||
|
||||
@include msg.sol.texi
|
||||
|
||||
@include multihash.sol.texi
|
||||
|
||||
@include registry.sol.texi
|
||||
|
||||
@include seal.sol.texi
|
||||
|
31
doc/texinfo/seal.sol.texi
Normal file
31
doc/texinfo/seal.sol.texi
Normal 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
|
@ -24,4 +24,6 @@ Edit access control lists.
|
||||
@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
|
||||
|
27
solidity/AccountsIndexMutable.sol
Normal file
27
solidity/AccountsIndexMutable.sol
Normal 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);
|
||||
}
|
11
solidity/Chrono.sol
Normal file
11
solidity/Chrono.sol
Normal 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);
|
||||
}
|
23
solidity/Digest.sol
Normal file
23
solidity/Digest.sol
Normal 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);
|
||||
}
|
15
solidity/ERC5007.sol
Normal file
15
solidity/ERC5007.sol
Normal 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
17
solidity/ERC5192.sol
Normal 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);
|
||||
}
|
@ -2,7 +2,7 @@ pragma solidity >=0.6.12;
|
||||
|
||||
// Author: Louis Holbrook <dev@holbrook.no> 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
// File-version: 3
|
||||
// File-version: 4
|
||||
|
||||
interface ILocator {
|
||||
// URI that may or may not point to a specific resource location.
|
||||
|
@ -15,8 +15,10 @@ interface IMultiHash {
|
||||
}
|
||||
|
||||
// All registered multicodecs
|
||||
function multiCodec(uint256 _codec) external view returns(MultiHash memory);
|
||||
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 toMultiHash(uint256 _codec, bytes memory _digest) external view returns(bytes memory);
|
||||
function encodeDigest(uint256 _codec, bytes memory _digest) external view returns(bytes memory);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user