Add Digest interface

This commit is contained in:
lash
2023-03-26 12:04:31 +01:00
parent 1e11d8df08
commit b3f6e45696
16 changed files with 171 additions and 30 deletions

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);
}

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);
}

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);
}

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);
}

View File

@@ -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.

View File

@@ -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);
}