From 46cc35b54c06e526a70b110a8e1c8ce0351b4b93 Mon Sep 17 00:00:00 2001 From: lash Date: Sat, 25 Mar 2023 12:32:56 +0000 Subject: [PATCH] Add back ERC interfaces --- doc/texinfo/multihash.sol.texi | 2 +- doc/texinfo/overview.texi | 8 +++++--- doc/texinfo/registry.sol.texi | 2 +- doc/texinfo/writer.sol.texi | 4 +++- solidity/AccountsIndex.sol | 2 +- solidity/Burner.sol | 4 ++-- solidity/Declarator.sol | 2 +- solidity/ERC165.sol | 12 ++++++++++++ solidity/ERC173.sol | 16 ++++++++++++++++ solidity/ERC20.sol | 24 ++++++++++++++++++++++++ solidity/ERC5679Ext20.sol | 14 ++++++++++++++ solidity/ERC5679Ext721.sol | 14 ++++++++++++++ solidity/ERC721.sol | 25 +++++++++++++++++++++++++ solidity/ERC721Enumerable.sol | 15 +++++++++++++++ solidity/ERC721Metadata.sol | 15 +++++++++++++++ solidity/ERC721Receiver.sol | 13 +++++++++++++ solidity/Expire.sol | 4 ++-- solidity/Faucet.sol | 4 ++-- solidity/Locator.sol | 2 +- solidity/Minter.sol | 4 ++-- solidity/MultiHash.sol | 2 +- solidity/OwnedAccepter.sol | 8 ++++---- solidity/OwnedTaker.sol | 6 +++--- solidity/Registry.sol | 2 +- solidity/RegistryClient.sol | 2 +- solidity/Seal.sol | 16 ++++++++++++++++ solidity/Writer.sol | 6 +++--- 27 files changed, 198 insertions(+), 30 deletions(-) create mode 100644 solidity/ERC165.sol create mode 100644 solidity/ERC173.sol create mode 100644 solidity/ERC20.sol create mode 100644 solidity/ERC5679Ext20.sol create mode 100644 solidity/ERC5679Ext721.sol create mode 100644 solidity/ERC721.sol create mode 100644 solidity/ERC721Enumerable.sol create mode 100644 solidity/ERC721Metadata.sol create mode 100644 solidity/ERC721Receiver.sol create mode 100644 solidity/Seal.sol diff --git a/doc/texinfo/multihash.sol.texi b/doc/texinfo/multihash.sol.texi index 24e5609..f48643f 100644 --- a/doc/texinfo/multihash.sol.texi +++ b/doc/texinfo/multihash.sol.texi @@ -1,6 +1,6 @@ @subsection Multihash -A complement to @code{Locator}, enabling validation and generation for multihashes that have been registered to the contract. +A complement to @code{Locator}, enabling validation and generation of multihashes for multicodecs that have been registered to the contract. @table @dfn diff --git a/doc/texinfo/overview.texi b/doc/texinfo/overview.texi index d4c541d..e434119 100644 --- a/doc/texinfo/overview.texi +++ b/doc/texinfo/overview.texi @@ -14,6 +14,7 @@ CIC smart contracts are implemented using the @emph{solidity} programming langua The following well-known solidity interfaces are used directly. + @itemize @bullet @item @uref{https://eips.ethereum.org/EIPS/eip-20, ERC20 - Token Standard} @@ -26,7 +27,7 @@ The following well-known solidity interfaces are used directly. @end itemize -@subsection Extended ERC definitions +@subsection Partial use @itemize @dfn @item @@ -34,7 +35,7 @@ The following well-known solidity interfaces are used directly. @end itemize -@section Native implementations +@section Native interfaces @include accountsindex.sol.texi @@ -56,5 +57,6 @@ The following well-known solidity interfaces are used directly. @include registry.sol.texi -@include writer.sol.texi +@include seal.sol.texi +@include writer.sol.texi diff --git a/doc/texinfo/registry.sol.texi b/doc/texinfo/registry.sol.texi index 9c0c02c..a19c3f0 100644 --- a/doc/texinfo/registry.sol.texi +++ b/doc/texinfo/registry.sol.texi @@ -16,7 +16,7 @@ Unique (ERC20) token symbol resolver. @include ../../build/RegistryClient.interface @item Solidity interface definition @include ../../build/contract_RegistryClient.texi -@item Reference implementation +@item Contract registry implementation @uref{git://holbrook.no/eth-contract-registry.git,} @item Token index implementation @uref{git://holbrook.no/eth-contract-registry.git,} diff --git a/doc/texinfo/writer.sol.texi b/doc/texinfo/writer.sol.texi index 1e794aa..25d0756 100644 --- a/doc/texinfo/writer.sol.texi +++ b/doc/texinfo/writer.sol.texi @@ -2,7 +2,9 @@ A complement to ERC173, which allows definition of a class of super-users for a contract. -Typically, 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}. +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}. + +No super-user should be able to perform actions that @emph{contract owner} cannot perform. Typically, only the @emph{contract owner} can add or remove a super-user. diff --git a/solidity/AccountsIndex.sol b/solidity/AccountsIndex.sol index 2d86250..c2670b0 100644 --- a/solidity/AccountsIndex.sol +++ b/solidity/AccountsIndex.sol @@ -4,7 +4,7 @@ pragma solidity >=0.6.12; // SPDX-License-Identifier: AGPL-3.0-or-later // File-version: 5 -interface AccountsIndex { +interface IAccountsIndex { event AddressAdded(address indexed addedAccount, uint256 indexed accountIndex); // AccountsIndex event AddressActive(address indexed _executor, address indexed _account, bool _active); event AddressRemoved(address indexed _executor, address _account); diff --git a/solidity/Burner.sol b/solidity/Burner.sol index 4f1805d..c41c316 100644 --- a/solidity/Burner.sol +++ b/solidity/Burner.sol @@ -1,10 +1,10 @@ pragma solidity >=0.6.12; // Author: Louis Holbrook 0826EDA1702D1E87C6E2875121D2E7BB88C2A746 -// SPDX-License-Identifier: GPL-3.0-or-later +// SPDX-License-Identifier: AGPL-3.0-or-later // File-version: 3 -interface Burner { +interface IBurner { // Token(s) successfully burned; by who and how much. event Burn(address indexed _burner, uint256 _burned); diff --git a/solidity/Declarator.sol b/solidity/Declarator.sol index dbd39de..7db3b00 100644 --- a/solidity/Declarator.sol +++ b/solidity/Declarator.sol @@ -4,7 +4,7 @@ pragma solidity >=0.6.12; // SPDX-License-Identifier: AGPL-3.0-or-later // File-version: 3 -interface Declarator { +interface IDeclarator { event DeclarationAdded(address indexed _declarator, address indexed _subject, bytes32 indexed _topic, bytes32 _proof); // Get all declarations for a subject (without topic) signed by a declarator diff --git a/solidity/ERC165.sol b/solidity/ERC165.sol new file mode 100644 index 0000000..47bedc4 --- /dev/null +++ b/solidity/ERC165.sol @@ -0,0 +1,12 @@ +pragma solidity >=0.6.12; + +// Author: Louis Holbrook 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 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 +interface IERC165 { + function supportsInterface(bytes4 _sum) external pure returns (bool); +} diff --git a/solidity/ERC173.sol b/solidity/ERC173.sol new file mode 100644 index 0000000..4a38070 --- /dev/null +++ b/solidity/ERC173.sol @@ -0,0 +1,16 @@ +pragma solidity >=0.6.12; + +// Author: Louis Holbrook 0826EDA1702D1E87C6E2875121D2E7BB88C2A746 +// 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 and Dan Finlay 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 IERC173 { + event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); + + function owner() external view returns (address); + function transferOwnership(address _newOwner) external view returns (bool); +} diff --git a/solidity/ERC20.sol b/solidity/ERC20.sol new file mode 100644 index 0000000..018f141 --- /dev/null +++ b/solidity/ERC20.sol @@ -0,0 +1,24 @@ +pragma solidity >=0.6.12; + +// Author: Louis Holbrook 0826EDA1702D1E87C6E2875121D2E7BB88C2A746 +// 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 IERC20 { + event Transfer(address indexed _from, address indexed _to, uint256 _value); + event Approval(address indexed _owner, address indexed _spender, uint256 _value); + + function transfer(address _to, uint256 _value) external returns (bool); + function transferFrom(address _from, address _to, uint256 _value) external returns (bool); + function approve(address _spender, uint256 _value) external returns (bool); + function name() external view returns (string memory); + function symbol() external view returns (string memory); + function decimals() external view returns (uint256); + function totalSupply() external view returns (uint256); + function allowance(address _owner, address _spender) external view returns(uint256); + function balanceOf(address _holder) external view returns (uint256); +} diff --git a/solidity/ERC5679Ext20.sol b/solidity/ERC5679Ext20.sol new file mode 100644 index 0000000..42056a2 --- /dev/null +++ b/solidity/ERC5679Ext20.sol @@ -0,0 +1,14 @@ +pragma solidity >=0.6.12; + +// Author: Louis Holbrook 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; +} diff --git a/solidity/ERC5679Ext721.sol b/solidity/ERC5679Ext721.sol new file mode 100644 index 0000000..d123769 --- /dev/null +++ b/solidity/ERC5679Ext721.sol @@ -0,0 +1,14 @@ +pragma solidity >=0.6.12; + +// Author: Louis Holbrook 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; +} diff --git a/solidity/ERC721.sol b/solidity/ERC721.sol new file mode 100644 index 0000000..c3b5375 --- /dev/null +++ b/solidity/ERC721.sol @@ -0,0 +1,25 @@ +pragma solidity >=0.6.12; + +// Author: Louis Holbrook 0826EDA1702D1E87C6E2875121D2E7BB88C2A746 +// 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 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) 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; + function getApproved(uint256 _tokenId) external view returns (address); + function isApprovedForAll(address _owner, address _operator) external view returns (bool); +} diff --git a/solidity/ERC721Enumerable.sol b/solidity/ERC721Enumerable.sol new file mode 100644 index 0000000..01a35e4 --- /dev/null +++ b/solidity/ERC721Enumerable.sol @@ -0,0 +1,15 @@ +pragma solidity >=0.6.12; + +// Author: Louis Holbrook 0826EDA1702D1E87C6E2875121D2E7BB88C2A746 +// 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 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); +} diff --git a/solidity/ERC721Metadata.sol b/solidity/ERC721Metadata.sol new file mode 100644 index 0000000..d3a97ac --- /dev/null +++ b/solidity/ERC721Metadata.sol @@ -0,0 +1,15 @@ +pragma solidity >=0.6.12; + +// Author: Louis Holbrook 0826EDA1702D1E87C6E2875121D2E7BB88C2A746 +// 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 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); +} diff --git a/solidity/ERC721Receiver.sol b/solidity/ERC721Receiver.sol new file mode 100644 index 0000000..6d2e004 --- /dev/null +++ b/solidity/ERC721Receiver.sol @@ -0,0 +1,13 @@ +pragma solidity >=0.6.12; + +// Author: Louis Holbrook 0826EDA1702D1E87C6E2875121D2E7BB88C2A746 +// 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 IERC721Receiver { + function onERC721Received(address _operator, address _from, uint256 _tokenId, bytes memory _data) external returns(bytes4); +} diff --git a/solidity/Expire.sol b/solidity/Expire.sol index e99386e..4cb6af4 100644 --- a/solidity/Expire.sol +++ b/solidity/Expire.sol @@ -1,10 +1,10 @@ pragma solidity >=0.6.12; // Author: Louis Holbrook 0826EDA1702D1E87C6E2875121D2E7BB88C2A746 -// SPDX-License-Identifier: GPL-3.0-or-later +// SPDX-License-Identifier: AGPL-3.0-or-later // File-version: 2 -interface Expire { +interface IExpire { // Expiration timestamp has been changed. event Expired(uint256 _timestamp); diff --git a/solidity/Faucet.sol b/solidity/Faucet.sol index 20eff7d..accda92 100644 --- a/solidity/Faucet.sol +++ b/solidity/Faucet.sol @@ -1,10 +1,10 @@ pragma solidity >=0.6.12; // Author: Louis Holbrook 0826EDA1702D1E87C6E2875121D2E7BB88C2A746 -// SPDX-License-Identifier: GPL-3.0-or-later +// SPDX-License-Identifier: AGPL-3.0-or-later // File-version: 6 -interface Faucet { +interface IFaucet { // Tokens were given to an address event Give(address indexed _recipient, address indexed _token, uint256 _value); diff --git a/solidity/Locator.sol b/solidity/Locator.sol index 2c2b01a..dc21167 100644 --- a/solidity/Locator.sol +++ b/solidity/Locator.sol @@ -1,7 +1,7 @@ pragma solidity >=0.6.12; // Author: Louis Holbrook 0826EDA1702D1E87C6E2875121D2E7BB88C2A746 -// SPDX-License-Identifier: GPL-3.0-or-later +// SPDX-License-Identifier: AGPL-3.0-or-later // File-version: 3 interface ILocator { diff --git a/solidity/Minter.sol b/solidity/Minter.sol index a560129..5757a39 100644 --- a/solidity/Minter.sol +++ b/solidity/Minter.sol @@ -1,10 +1,10 @@ pragma solidity >=0.6.12; // Author: Louis Holbrook 0826EDA1702D1E87C6E2875121D2E7BB88C2A746 -// SPDX-License-Identifier: GPL-3.0-or-later +// 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); diff --git a/solidity/MultiHash.sol b/solidity/MultiHash.sol index 52746c4..2b76211 100644 --- a/solidity/MultiHash.sol +++ b/solidity/MultiHash.sol @@ -1,7 +1,7 @@ pragma solidity >=0.6.12; // Author: Louis Holbrook 0826EDA1702D1E87C6E2875121D2E7BB88C2A746 -// SPDX-License-Identifier: GPL-3.0-or-later +// SPDX-License-Identifier: AGPL-3.0-or-later // File-version: 2 interface IMultiHash { diff --git a/solidity/OwnedAccepter.sol b/solidity/OwnedAccepter.sol index 69f8f74..b2e40aa 100644 --- a/solidity/OwnedAccepter.sol +++ b/solidity/OwnedAccepter.sol @@ -1,9 +1,9 @@ -pragma solidity ^0.8.0; +pragma solidity >=0.6.12; // Author: Louis Holbrook 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); } diff --git a/solidity/OwnedTaker.sol b/solidity/OwnedTaker.sol index 96b48cb..a6149d0 100644 --- a/solidity/OwnedTaker.sol +++ b/solidity/OwnedTaker.sol @@ -1,8 +1,8 @@ -pragma solidity ^0.8.0; +pragma solidity >=0.6.12; // Author: Louis Holbrook 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); diff --git a/solidity/Registry.sol b/solidity/Registry.sol index 620b323..c3bd492 100644 --- a/solidity/Registry.sol +++ b/solidity/Registry.sol @@ -4,7 +4,7 @@ pragma solidity >=0.6.12; // 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); } diff --git a/solidity/RegistryClient.sol b/solidity/RegistryClient.sol index 24625ee..1cedd10 100644 --- a/solidity/RegistryClient.sol +++ b/solidity/RegistryClient.sol @@ -4,7 +4,7 @@ pragma solidity >=0.6.12; // SPDX-License-Identifier: AGPL-3.0-or-later // File-version: 3 -interface RegistryClient { +interface IRegistryClient { // Return the address of the contract identified by the given byte string function addressOf(bytes32) external view returns (address); diff --git a/solidity/Seal.sol b/solidity/Seal.sol new file mode 100644 index 0000000..44a5584 --- /dev/null +++ b/solidity/Seal.sol @@ -0,0 +1,16 @@ +pragma solidity >=0.6.12; + +// Author: Louis Holbrook 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); +} diff --git a/solidity/Writer.sol b/solidity/Writer.sol index 7554c8b..bcd2553 100644 --- a/solidity/Writer.sol +++ b/solidity/Writer.sol @@ -1,10 +1,10 @@ pragma solidity >=0.6.12; // Author: Louis Holbrook 0826EDA1702D1E87C6E2875121D2E7BB88C2A746 -// SPDX-License-Identifier: GPL-3.0-or-later -// File-version: 2 +// SPDX-License-Identifier: AGPL-3.0-or-later +// File-version: 3 -interface Writer { +interface IWriter { // A writer has been added by _executor event WriterAdded(address indexed _executor, address _writer);