Skip to content

Commit

Permalink
Fixing PR comments and issues (#3)
Browse files Browse the repository at this point in the history
* Updated the Specification section + replaced the png with and svg file + Fixed the assets issue with package-lock

* Fixed the licence in the KBT contract

---------

Co-authored-by: KBT Admin <kbtstandard@proton.me>
  • Loading branch information
NarcisCRO and KBTStandardAdmin authored Apr 18, 2023
1 parent 6918a43 commit 89f6237
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 17,524 deletions.
138 changes: 9 additions & 129 deletions EIPS/eip-6809.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ The functions detailed below MUST be implemented.

Secures the sender account with other two wallets called `_keyWallet1` and `_keyWallet2` and MUST fire the `AccountSecured` event.

The function SHOULD `throw` if:
The function SHOULD `revert` if:

- the sender account is not a holder
- or the sender is already secured
Expand Down Expand Up @@ -260,7 +260,7 @@ function getBindings(address _account) external view returns (AccountHolderBindi

Called from a `keyWallet`, the function resets the `keyWallets` for the `holder` account. MUST fire the `AccountResetBinding` event.

The function SHOULD `throw` if the sender is not a `keyWallet`.
The function SHOULD `revert` if the sender is not a `keyWallet`.

```solidity
function resetBindings() external returns (bool)
Expand All @@ -272,7 +272,7 @@ function resetBindings() external returns (bool)

Called from a `keyWallet`, this function transfers all the tokens from the `holder` account to the other `keyWallet` and MUST fire the `SafeFallbackActivated` event.

The function SHOULD `throw` if the sender is not a `keyWallet`.
The function SHOULD `revert` if the sender is not a `keyWallet`.

```solidity
function safeFallback() external returns (bool);
Expand All @@ -291,7 +291,7 @@ Or if `_anyToken` is `true`, regardless of the other params, it allows any token

The function MUST fire `AccountEnabledTransfer` event.

The function SHOULD `throw` if the sender is not a `keyWallet` for a holder or if the owner of the `_tokenId` is different than the `holder`.
The function SHOULD `revert` if the sender is not a `keyWallet` for a holder or if the owner of the `_tokenId` is different than the `holder`.

```solidity
function allowTransfer(uint256 _tokenId, uint256 _time, address _to, bool _anyToken) external returns (bool);
Expand Down Expand Up @@ -322,7 +322,7 @@ It allows the `holder` for a specific amount of `_time` to do an `approve` or `s

The function MUST fire `AccountEnabledApproval` event.

The function SHOULD `throw` if the sender is not a `keyWallet`.
The function SHOULD `revert` if the sender is not a `keyWallet`.

```solidity
function allowApproval(uint256 _time) external returns (bool)
Expand Down Expand Up @@ -352,7 +352,7 @@ and when that happens, the approval is revoked using a set approval for all to `

The function MUST fire the `Transfer` event.

The function SHOULD `throw` if:
The function SHOULD `revert` if:

- the sender is not the owner or is not approved to transfer the `_tokenId`
- or if the `_from` address is not the owner of the `_tokenId`
Expand All @@ -368,7 +368,7 @@ The function transfers from `_from` address to `_to` address the `_tokenId` toke

The function MUST fire the `Transfer` event.

The function SHOULD `throw` if:
The function SHOULD `revert` if:

- the sender is not the owner or is not approved to transfer the `_tokenId`
- or if the `_from` address is not the owner of the `_tokenId`
Expand Down Expand Up @@ -396,7 +396,7 @@ The function MUST fire an `Approval` event.

If the function is called again it overrides the number of transfers allowed with `_numberOfTransfers`, set in `allowApproval` function.

The function SHOULD `throw` if:
The function SHOULD `revert` if:

- the sender is not the current NFT owner, or an authorized operator of the current owner
- the NFT owner is secured and has not called `allowApproval` function
Expand All @@ -416,7 +416,7 @@ The function Emits an `Approval` event indicating the updated allowance.

If the function is called again it overrides the number of transfers allowed with `_numberOfTransfers`, set in `allowApproval` function.

The function SHOULD `throw` if:
The function SHOULD `revert` if:

- the sender account is secured and has not called `allowApproval` function
- or if the `_spender` is a zero address (`0x0`)
Expand All @@ -426,126 +426,6 @@ The function SHOULD `throw` if:
function setApprovalForAll(address _operator, bool _approved) public virtual override(ERC721, IERC721)
```

---

### **Internal functions**

#### `_hasAllowedTransfer` function

The function returns `true` if:

- the `_account` has allowed for transfer any token through `_anyToken` parameter
- or the `_account` has allowed for transfer a `_tokenId`, for `_to` address and if the `time` has not elapsed

In all other cases the function will return `false`.

```solidity
function _hasAllowedTransfer(
address _account,
uint256 _tokenId,
address _to
) internal view returns (bool) {
TransferConditions memory conditions = _transferConditions[_account];
if (conditions.anyToken) {
return true;
}
if (
(conditions.tokenId == 0 &&
conditions.time == 0 &&
conditions.to == address(0)) ||
(conditions.tokenId > 0 && conditions.tokenId != _tokenId) ||
(conditions.time > 0 && conditions.time < block.timestamp) ||
(conditions.to != address(0) && conditions.to != _to)
) {
return false;
}
return true;
}
```

#### `_getAccountHolder` function

This function identifies and returns the `_holder` account starting from the `sender` address.

If the `sender` is not a `keyWallet` zero address is returned (`0x0`).

```solidity
function _getAccountHolder() internal view returns (address) {
address sender = _msgSender();
return
_firstAccounts[sender].accountHolderWallet != address(0)
? _firstAccounts[sender].accountHolderWallet
: (
_secondAccounts[sender].accountHolderWallet != address(0)
? _secondAccounts[sender].accountHolderWallet
: address(0)
);
}
```

#### `_getOtherSecureWallet` function

This function identifies and returns the other `keyWallet` starting from the `sender` address.

If the `sender` is not a `keyWallet` zero address is returned (`0x0`).

```solidity
function _getOtherSecureWallet() internal view returns (address) {
address sender = _msgSender();
address accountHolder = _getAccountHolder();
return
_holderAccounts[accountHolder].firstWallet == sender
? _holderAccounts[accountHolder].secondWallet
: _holderAccounts[accountHolder].firstWallet;
}
```

#### `_isApprovalAllowed` function

This function returns `true` if the `_time`, set in `allowApproval` function, has not elapsed yet.

```solidity
function _isApprovalAllowed(address account) internal view returns (bool) {
return _allowApproval[account] >= block.timestamp;
}
```

#### `_afterTokenTransfer` function

This function is called after a successful `transfer`, `transferFrom`, `mint` and `burn`.

This function fires `Egress` event when loosing a holder and `Ingress` event when gaining a holder.

```solidity
function _afterTokenTransfer(
address _from,
address _to,
uint256 _firstTokenId,
uint256 _batchSize
) internal virtual override {
if (_from != address(0)) {
// region update secureAccounts
if (isSecureWallet(_from) && balanceOf(_from) == 0) {
delete _firstAccounts[_holderAccounts[_from].firstWallet];
delete _secondAccounts[_holderAccounts[_from].secondWallet];
delete _holderAccounts[_from];
}
// endregion
if (balanceOf(_from) == 0) {
emit Egress(_from, _firstTokenId);
}
}
if (_to != address(0) && balanceOf(_to) == _batchSize) {
emit Ingress(_to, _firstTokenId);
}
}
```

## Rationale

The intent from individual technical decisions made during the development of **NFKBTs** focused on maintaining consistency and backward compatibility with _ERC-721s_, all the while offering self-custodial security features to the user. It was important that **NFKBTs** inherited all of the _ERC-721s_ characteristics to comply with requirements found in dApps which use non-fungible tokens on their platform. In doing so, it allowed for flawless backward compatibility to take place and gave the user the choice to decide if they want their **NFKBTs** to act with **Default Behaviours**[^22]. We wanted to ensure that wide-scale implementation and adoption of **NFKBTs** could take place immediately, without the greater collective needing to adapt and make changes to the already flourishing decentralized ecosystem.
Expand Down
1 change: 1 addition & 0 deletions assets/eip-6809/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules/
build/
.env
.vscode
package-lock.json
1 change: 1 addition & 0 deletions assets/eip-6809/Contract Interactions diagram.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/eip-6809/Contract interactions diagram.png
Binary file not shown.
2 changes: 1 addition & 1 deletion assets/eip-6809/contracts/KBT721.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.17;

import "./IKBT721.sol";
Expand Down
Loading

0 comments on commit 89f6237

Please sign in to comment.