aionnetwork / AIP

Network & Protocol Improvement Proposals for Aion
https://aion.network
16 stars 13 forks source link

AIP-011: Ownable Smart Contract #21

Open patitonar opened 5 years ago

patitonar commented 5 years ago

Title: Ownable Smart Contract

Author(s): Manuel Garcia, Pavel Orda

Type: ASC (Aion Standards and Conventions)

Status: DRAFT

Creation Date: May 28th, 2019

Contact Information: manuel.garcia@altoros.com

Related issue: https://github.com/aionnetwork/AIP/issues/22

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 function

Returns the address of the current owner.

returns: Address of the owner

public static Address getOwner()

renounceOwnership function

Leaves the contract without owner. Can only be called by the current owner.

Note: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.

public static void renounceOwnership()

transferOwnership function

Transfers ownership of the contract to a new account (newOwner). Can only be called by the current owner.

public static void transferOwnership(Address newOwner)

parameters
tokenHolder: Address for which the balance is returned.

onlyOwner function

Stops transaction if called by any account other than the owner. Do not work for function calls

private static void onlyOwner()

OwnershipTransferred event

Indicates ownership change form oldOwner address to newOwner address.

parameters
oldOwner: Address of previous owner.
newOwner: Address of new owner.

private static void emitOwnershipTransferredEvent(Address oldOwner, Address newOwner)

Dependencies

Copyright

All AIP’s are public domain. Copyright waiver to be linked to https://creativecommons.org/publicdomain/zero/1.0/