-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AIP-011: Ownable Smart Contract #22
Comments
For the constants public static class Const {
public static final Address NO_ADDRESS = new Address(new byte[32]);
public static final String OWNERSHIP_TRANSFERRED = "OwnershipTransferred";
}
private static Address owner = NO_ADDRESS; Will it be better to just assign them as constants instead of putting them into a static class, since extra class namespace will cost more energy? Also, it will be cheaper to have private static final Address NO_ADDRESS = new Address(new byte[32]);
private static final byte[] OWNERSHIP_TRANSFERRED = "OwnershipTransferred".getBytes(); |
private static boolean isOwner() {
Address caller = Blockchain.getCaller();
return owner.equals(caller);
} I think @Callable
public static boolean isOwner() {
return owner.equals( Blockchain.getCaller();
} |
private static void onlyOwner() {
Blockchain.require(isOwner());
}
private static boolean isOwner() {
Address caller = Blockchain.getCaller();
return owner.equals(caller);
} It maybe cheaper if just do private static void onlyOwner() }
Blockchain.require(Blockchain.getcaller().equals(owner));
} |
Hey @patitonar, thank you for submitting the AIP. |
Java compiler will do this automatically. |
I removed |
@jennijuju Thanks for the feedback! This PR https://github.com/protofire/AIP-011-Ownable/pull/4/files add the suggested changes |
Title: Ownable Smart Contract
Author(s): Manuel Garcia, Pavel Orda
Type: ASC (Aion Standards and Conventions)
Status: REVIEW
Creation Date: May 28th, 2019
Contact Information: [email protected]
Summary
Contract module for simple authorization and access control mechanisms.
Value Proposition
Contract module which provides a basic access control mechanism, where there is an account (an owner) that can be granted exclusive access to specific functions.
Motivation
This module could be used through inheritance. It will make available the modifier
onlyOwner
, which can be aplied to your functions to restrict their use to the owner.Non-Goals
Success Metrics
Description
Specification
Based on Solidity implementation https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/ownership/Ownable.sol
Logic
Risks & Assumptions
Test Cases
Test cases reference implementation
Implementations
Definitions
Reference implementation
Methods
getOwner
functionReturns the address of the current owner.
renounceOwnership
functionLeaves the contract without owner. Can only be called by the current owner.
transferOwnership
functionTransfers ownership of the contract to a new account (
newOwner
).Can only be called by the current owner.
onlyOwner
functionStops transaction if called by any account other than the owner.
Do not work for function calls
OwnershipTransferred
eventIndicates ownership change form
oldOwner
address tonewOwner
address.Dependencies
Copyright
All AIP’s are public domain. Copyright waiver to be linked
to https://creativecommons.org/publicdomain/zero/1.0/
The text was updated successfully, but these errors were encountered: