erc6551 / reference

ERC-6551 reference implementation
152 stars 50 forks source link

Update EIP-6551: Preventing circular lock situation with initialize #15

Open Abhijaypaliwal opened 1 year ago

Abhijaypaliwal commented 1 year ago

Description

This pull request adds the initialize function for EIP-6551 as described in the guidelines. The initialize function can be called by the owner after ownership change to set the currOwner and prevOwner variables. Additionally, the unlockCircularLock function is introduced to handle situations of circular lock, allowing the previous owner to unlock it.

Changes

Added Functions

Modifications

Tests

Motivation

This enhancement is in line with the objectives of EIP-6551 and provides additional functionalities for handling ownership transitions and circular lock scenarios.

Usage

  1. After ownership change, the new owner can call the initialize function to set the current owner (currOwner) and previous owner (prevOwner) variables.

  2. In cases of circular lock, the previous owner can use the unlockCircularLock function to release the lock.

Issues

The initialize function could only be used to change previousOwner. and this value could only be used for account recovery. however if new owner of Token transfer it to another owner without initialization, the previousOwner is not changed, hence the recovery can be done by third last owner and he can call it without any restriction, which could be malicious.

Checklist