Skip to content

Commit

Permalink
support display method; support eip165 (#213)
Browse files Browse the repository at this point in the history
* add displayMethod to the credential

* use ERC165 to check interface implementation

* support type for credentialSchema
  • Loading branch information
ilya-korotya authored Feb 22, 2024
1 parent 5bfd807 commit 36acb8a
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 15 deletions.
30 changes: 24 additions & 6 deletions contracts/interfaces/INonMerklizedIssuer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,23 @@ pragma solidity 0.8.16;
* @dev INonMerklizedIssuer. Interface for non-merklized issuer
*/
interface INonMerklizedIssuer {
/**
* @dev DisplayMethod display method for the credential
* Optional fields
*/
struct DisplayMethod {
string id;
string _type;
}

/**
* @dev CredentialSchema. Schema for the credential
*/
struct CredentialSchema {
string id;
string _type;
}

/**
* @dev CredentialInformation. Information about the credential
*/
Expand All @@ -13,7 +30,8 @@ interface INonMerklizedIssuer {
string[] context;
string _type;
uint64 issuanceDate;
string credentialSchema;
CredentialSchema credentialSchema;
DisplayMethod displayMethod;
}

/**
Expand All @@ -30,10 +48,10 @@ interface INonMerklizedIssuer {
}

/**
* @dev listUserCredentialIds. Get list of user credentials identifiers
* @dev getUserCredentialIds. Get list of user credentials identifiers
* @param _userId user id
*/
function listUserCredentialIds(uint256 _userId) external returns (uint256[] memory);
function getUserCredentialIds(uint256 _userId) external view returns (uint256[] memory);

/**
* @dev getCredential. Get credential by user id and credential id.
Expand All @@ -44,10 +62,10 @@ interface INonMerklizedIssuer {
function getCredential(
uint256 _userId,
uint256 _credentialId
) external returns (CredentialData memory, uint256[8] memory, SubjectField[] memory);
) external view returns (CredentialData memory, uint256[8] memory, SubjectField[] memory);

/**
* @dev getCredentialProtocolVersion. Get version of the protocol
* @dev getCredentialAdapterVersion. Get version of the credential adapter
*/
function getCredentialProtocolVersion() external returns (string memory);
function getCredentialAdapterVersion() external view returns (string memory);
}
23 changes: 17 additions & 6 deletions contracts/lib/NonMerklizedIssuerBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,31 @@
pragma solidity 0.8.16;

import {INonMerklizedIssuer} from "../interfaces/INonMerklizedIssuer.sol";
import {IdentityBase} from "./IdentityBase.sol";
import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";

/**
* @dev NonMerklizedIssuerBase. Non-merklized base contract to issue non-merklized credentials
*/
abstract contract NonMerklizedIssuerBase is INonMerklizedIssuer {
abstract contract NonMerklizedIssuerBase is INonMerklizedIssuer, IdentityBase, ERC165 {
/**
* @dev Constant representing the protocol version
* @dev Constant representing the credential adapter version
*/
string public constant CREDENTIAL_PROTOCOL_VERSION = "0.0.1";
string public constant CREDENTIAL_ADAPTER_VERSION = "0.0.1";

/**
* @dev getCredentialProtocolVersion. Get version of the credential protocol
* @dev getCredentialAdapterVersion. Get version of the credential adapter
*/
function getCredentialProtocolVersion() external pure returns (string memory) {
return CREDENTIAL_PROTOCOL_VERSION;
function getCredentialAdapterVersion() external pure returns (string memory) {
return CREDENTIAL_ADAPTER_VERSION;
}

/**
* @dev supportsInterface. Check if the contract supports the interface
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return
interfaceId == type(INonMerklizedIssuer).interfaceId ||
super.supportsInterface(interfaceId);
}
}
4 changes: 2 additions & 2 deletions contracts/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion contracts/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@iden3/contracts",
"description": "Smart Contract library for Solidity",
"version": "1.4.7",
"version": "1.4.8",
"files": [
"**/*.sol",
"/build/contracts/*.json",
Expand Down

0 comments on commit 36acb8a

Please sign in to comment.