Skip to content

Commit 3031411

Browse files
committed
Add validator interfaces to examples
1 parent f08c2a5 commit 3031411

File tree

3 files changed

+149
-2
lines changed

3 files changed

+149
-2
lines changed

contracts/examples/token/ERC20/TPLERC20PermissionedInterface.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ interface TPLERC20PermissionedInterface {
1212
* @param value uint256 The amount to transfer.
1313
* @return Bool indicating if transfer will succeed & byte with a status code.
1414
*/
15-
function canTransfer(address to, uint256 value) public returns (bool, bytes1);
15+
function canTransfer(address to, uint256 value) external returns (bool, bytes1);
1616

1717
/**
1818
* @notice Check if an account is approved to transfer tokens on behalf of
@@ -26,7 +26,7 @@ interface TPLERC20PermissionedInterface {
2626
address from,
2727
address to,
2828
uint256 value
29-
) public returns (bool, bytes1);
29+
) external returns (bool, bytes1);
3030

3131
/**
3232
* @notice Get the account of the utilized attribute registry.
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
pragma solidity ^0.4.25;
2+
3+
4+
/**
5+
* @title TPL Basic Validator interface. EIP-165 ID: 0xd13d3f23
6+
*/
7+
interface TPLBasicValidatorInterface {
8+
/**
9+
* @notice Check if contract is assigned as a validator on the jurisdiction.
10+
* @return True if validator is assigned, false otherwise.
11+
*/
12+
function isValidator() external view returns (bool);
13+
14+
/**
15+
* @notice Check if the validator is approved to issue attributes of the type
16+
* with ID `attributeTypeID` on the jurisdiction.
17+
* @param attributeTypeID uint256 The ID of the attribute type in question.
18+
* @return True if validator is approved to issue attributes of given type.
19+
*/
20+
function canIssueAttributeType(
21+
uint256 attributeTypeID
22+
) external view returns (bool);
23+
24+
/**
25+
* @notice Check if the validator is approved to issue an attribute of the
26+
* type with ID `attributeTypeID` to account `account` on the jurisdiction.
27+
* @param account address The account to check for issuing the attribute to.
28+
* @param attributeTypeID uint256 The ID of the attribute type in question.
29+
* @return Bool indicating if attribute is issuable & byte with status code.
30+
*/
31+
function canIssueAttribute(
32+
address account,
33+
uint256 attributeTypeID
34+
) external view returns (bool, bytes1);
35+
36+
/**
37+
* @notice Check if the validator is approved to revoke an attribute of the
38+
* type with ID `attributeTypeID` from account `account` on the jurisdiction.
39+
* @param account address The checked account for revoking the attribute from.
40+
* @param attributeTypeID uint256 The ID of the attribute type in question.
41+
* @return Bool indicating if attribute is revocable & byte with status code.
42+
*/
43+
function canRevokeAttribute(
44+
address account,
45+
uint256 attributeTypeID
46+
) external view returns (bool, bytes1);
47+
48+
/**
49+
* @notice Issue an attribute of the type with ID `attributeTypeID` to account
50+
* `account` on the jurisdiction.
51+
* @param account address The account to issue the attribute to.
52+
* @param attributeTypeID uint256 The ID of the attribute type in question.
53+
* @dev Note that the function is payable - this is so that the function in
54+
* question can support both basic and extended jurisdictions. Attaching a
55+
* value when utilizing a basic jurisdiction will revert the transaction.
56+
*/
57+
function issueAttribute(
58+
address account,
59+
uint256 attributeTypeID
60+
) external payable;
61+
62+
/**
63+
* @notice Revoke an attribute of the type with ID `attributeTypeID` from
64+
* account `account` on the jurisdiction.
65+
* @param account address The account to revoke the attribute from.
66+
* @param attributeTypeID uint256 The ID of the attribute type in question.
67+
*/
68+
function revokeAttribute(address account, uint256 attributeTypeID) external;
69+
70+
/**
71+
* @notice Get account of utilized jurisdiction and associated attribute
72+
* registry managed by the jurisdiction.
73+
* @return The account of the jurisdiction.
74+
*/
75+
function getJurisdiction() external view returns (address);
76+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
pragma solidity ^0.4.25;
2+
3+
4+
/**
5+
* @title TPL Extended Validator interface (extends Basic Validator interface).
6+
* EIP-165 ID: 0x596c0405
7+
*/
8+
interface TPLExtendedValidatorInterface {
9+
/**
10+
* @notice Check if the validator is approved to issue an attribute of the
11+
* type with ID `attributeTypeID` to account `account` on the jurisdiction
12+
* when `msg.value` is set to `value`.
13+
* @param account address The account to issue the attribute to.
14+
* @param attributeTypeID uint256 The ID of the attribute type in question.
15+
* @param value uint256 The amount of ether included in the transaction.
16+
* @return Bool indicating if attribute is issuable & byte with status code.
17+
*/
18+
function canIssueAttribute(
19+
address account,
20+
uint256 attributeTypeID,
21+
uint256 value
22+
) external view returns (bool, bytes1);
23+
24+
/**
25+
* @notice Get the validator's signing key on the jurisdiction.
26+
* @return The account referencing the public component of the signing key.
27+
*/
28+
function getSigningKey() external view returns (address);
29+
30+
/**
31+
* @notice Set a signing key on the jurisdiction with an associated public
32+
* key at address `newSigningKey`.
33+
* @param newSigningKey address The signing key to set.
34+
*/
35+
function setSigningKey(address newSigningKey) external;
36+
37+
/**
38+
* @notice Get the hash of a given attribute approval from the jurisdiction
39+
* @param account address The account specified by the attribute approval.
40+
* @param operator address An optional account permitted to submit approval.
41+
* @param attributeTypeID uint256 The ID of the attribute type in question.
42+
* @param value uint256 The value of the attribute in the approval.
43+
* @param fundsRequired uint256 The amount to be included with the approval.
44+
* @param validatorFee uint256 The required fee to be paid to the validator.
45+
* @return The hash of the attribute approval.
46+
*/
47+
function getAttributeApprovalHash(
48+
address account,
49+
address operator,
50+
uint256 attributeTypeID,
51+
uint256 value,
52+
uint256 fundsRequired,
53+
uint256 validatorFee
54+
) external view returns (bytes32 hash);
55+
56+
/**
57+
* @notice Invalidate a signed attribute approval before it has been set by
58+
* supplying the hash of the approval `hash` and the signature `signature`.
59+
* @param hash bytes32 The hash of the attribute approval.
60+
* @param signature bytes The hash's signature, resolving to the signing key.
61+
*/
62+
function invalidateAttributeApproval(bytes32 hash, bytes signature) external;
63+
64+
/**
65+
* @notice Withdraw funds paid into the validator of amount `value` to the
66+
* account at `to`.
67+
* @param to address The address to withdraw to.
68+
* @param value uint256 The amount to withdraw.
69+
*/
70+
function withdraw(bytes32 to, uint256 value) external;
71+
}

0 commit comments

Comments
 (0)