contract_name
stringlengths 1
61
| file_path
stringlengths 5
50.4k
| contract_address
stringlengths 42
42
| language
stringclasses 1
value | class_name
stringlengths 1
61
| class_code
stringlengths 4
330k
| class_documentation
stringlengths 0
29.1k
| class_documentation_type
stringclasses 6
values | func_name
stringlengths 0
62
| func_code
stringlengths 1
303k
| func_documentation
stringlengths 2
14.9k
| func_documentation_type
stringclasses 4
values | compiler_version
stringlengths 15
42
| license_type
stringclasses 14
values | swarm_source
stringlengths 0
71
| meta
dict | __index_level_0__
int64 0
60.4k
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
GoodGamePlatform | ERC223.sol | 0x3ac655b147b6e2d2ced40126f6c5956e5467a92b | Solidity | ERC223Token | contract ERC223Token is ERC223 {
using SafeMath for uint;
mapping(address => uint) balances;
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
// Function to access name of token .
function name() constant returns (string _name) {
return name;
}
// Function to access symbol of token .
function symbol() constant returns (string _symbol) {
return symbol;
}
// Function to access decimals of token .
function decimals() constant returns (uint8 _decimals) {
return decimals;
}
// Function to access total supply of tokens .
function totalSupply() constant returns (uint256 _totalSupply) {
return totalSupply;
}
// Function that is called when a user or another contract wants to transfer funds .
function transfer(address _to, uint _value, bytes _data) returns (bool success) {
if(isContract(_to)) {
return transferToContract(_to, _value, _data);
}
else {
return transferToAddress(_to, _value, _data);
}
}
// Standard function transfer similar to ERC20 transfer with no _data .
// Added due to backwards compatibility reasons .
function transfer(address _to, uint _value) returns (bool success) {
//standard function transfer similar to ERC20 transfer with no _data
//added due to backwards compatibility reasons
bytes memory empty;
if(isContract(_to)) {
return transferToContract(_to, _value, empty);
}
else {
return transferToAddress(_to, _value, empty);
}
}
//assemble the given address bytecode. If bytecode exists then the _addr is a contract.
function isContract(address _addr) private returns (bool is_contract) {
uint length;
assembly {
//retrieve the size of the code on target address, this needs assembly
length := extcodesize(_addr)
}
if(length>0) {
return true;
}
else {
return false;
}
}
//function that is called when transaction target is an address
function transferToAddress(address _to, uint _value, bytes _data) private returns (bool success) {
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = balanceOf(msg.sender).sub(_value);
balances[_to] = balanceOf(_to).add(_value);
Transfer(msg.sender, _to, _value);
ERC223Transfer(msg.sender, _to, _value, _data);
return true;
}
//function that is called when transaction target is a contract
function transferToContract(address _to, uint _value, bytes _data) private returns (bool success) {
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = balanceOf(msg.sender).sub(_value);
balances[_to] = balanceOf(_to).add(_value);
ContractReceiver reciever = ContractReceiver(_to);
reciever.tokenFallback(msg.sender, _value, _data);
Transfer(msg.sender, _to, _value);
ERC223Transfer(msg.sender, _to, _value, _data);
return true;
}
function balanceOf(address _owner) constant returns (uint balance) {
return balances[_owner];
}
} | transfer | function transfer(address _to, uint _value, bytes _data) returns (bool success) {
if(isContract(_to)) {
return transferToContract(_to, _value, _data);
}
else {
return transferToAddress(_to, _value, _data);
}
| // Function that is called when a user or another contract wants to transfer funds . | LineComment | v0.4.25+commit.59dbf8f1 | bzzr://ab9f0fe42d9e16b9e57ac46a758e7fa8f126024174b2d499ea997543c325ce05 | {
"func_code_index": [
804,
1047
]
} | 9,100 |
|||
GoodGamePlatform | ERC223.sol | 0x3ac655b147b6e2d2ced40126f6c5956e5467a92b | Solidity | ERC223Token | contract ERC223Token is ERC223 {
using SafeMath for uint;
mapping(address => uint) balances;
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
// Function to access name of token .
function name() constant returns (string _name) {
return name;
}
// Function to access symbol of token .
function symbol() constant returns (string _symbol) {
return symbol;
}
// Function to access decimals of token .
function decimals() constant returns (uint8 _decimals) {
return decimals;
}
// Function to access total supply of tokens .
function totalSupply() constant returns (uint256 _totalSupply) {
return totalSupply;
}
// Function that is called when a user or another contract wants to transfer funds .
function transfer(address _to, uint _value, bytes _data) returns (bool success) {
if(isContract(_to)) {
return transferToContract(_to, _value, _data);
}
else {
return transferToAddress(_to, _value, _data);
}
}
// Standard function transfer similar to ERC20 transfer with no _data .
// Added due to backwards compatibility reasons .
function transfer(address _to, uint _value) returns (bool success) {
//standard function transfer similar to ERC20 transfer with no _data
//added due to backwards compatibility reasons
bytes memory empty;
if(isContract(_to)) {
return transferToContract(_to, _value, empty);
}
else {
return transferToAddress(_to, _value, empty);
}
}
//assemble the given address bytecode. If bytecode exists then the _addr is a contract.
function isContract(address _addr) private returns (bool is_contract) {
uint length;
assembly {
//retrieve the size of the code on target address, this needs assembly
length := extcodesize(_addr)
}
if(length>0) {
return true;
}
else {
return false;
}
}
//function that is called when transaction target is an address
function transferToAddress(address _to, uint _value, bytes _data) private returns (bool success) {
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = balanceOf(msg.sender).sub(_value);
balances[_to] = balanceOf(_to).add(_value);
Transfer(msg.sender, _to, _value);
ERC223Transfer(msg.sender, _to, _value, _data);
return true;
}
//function that is called when transaction target is a contract
function transferToContract(address _to, uint _value, bytes _data) private returns (bool success) {
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = balanceOf(msg.sender).sub(_value);
balances[_to] = balanceOf(_to).add(_value);
ContractReceiver reciever = ContractReceiver(_to);
reciever.tokenFallback(msg.sender, _value, _data);
Transfer(msg.sender, _to, _value);
ERC223Transfer(msg.sender, _to, _value, _data);
return true;
}
function balanceOf(address _owner) constant returns (uint balance) {
return balances[_owner];
}
} | transfer | function transfer(address _to, uint _value) returns (bool success) {
//standard function transfer similar to ERC20 transfer with no _data
//added due to backwards compatibility reasons
bytes memory empty;
if(isContract(_to)) {
return transferToContract(_to, _value, empty);
}
else {
return transferToAddress(_to, _value, empty);
}
| // Standard function transfer similar to ERC20 transfer with no _data .
// Added due to backwards compatibility reasons . | LineComment | v0.4.25+commit.59dbf8f1 | bzzr://ab9f0fe42d9e16b9e57ac46a758e7fa8f126024174b2d499ea997543c325ce05 | {
"func_code_index": [
1175,
1554
]
} | 9,101 |
|||
GoodGamePlatform | ERC223.sol | 0x3ac655b147b6e2d2ced40126f6c5956e5467a92b | Solidity | ERC223Token | contract ERC223Token is ERC223 {
using SafeMath for uint;
mapping(address => uint) balances;
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
// Function to access name of token .
function name() constant returns (string _name) {
return name;
}
// Function to access symbol of token .
function symbol() constant returns (string _symbol) {
return symbol;
}
// Function to access decimals of token .
function decimals() constant returns (uint8 _decimals) {
return decimals;
}
// Function to access total supply of tokens .
function totalSupply() constant returns (uint256 _totalSupply) {
return totalSupply;
}
// Function that is called when a user or another contract wants to transfer funds .
function transfer(address _to, uint _value, bytes _data) returns (bool success) {
if(isContract(_to)) {
return transferToContract(_to, _value, _data);
}
else {
return transferToAddress(_to, _value, _data);
}
}
// Standard function transfer similar to ERC20 transfer with no _data .
// Added due to backwards compatibility reasons .
function transfer(address _to, uint _value) returns (bool success) {
//standard function transfer similar to ERC20 transfer with no _data
//added due to backwards compatibility reasons
bytes memory empty;
if(isContract(_to)) {
return transferToContract(_to, _value, empty);
}
else {
return transferToAddress(_to, _value, empty);
}
}
//assemble the given address bytecode. If bytecode exists then the _addr is a contract.
function isContract(address _addr) private returns (bool is_contract) {
uint length;
assembly {
//retrieve the size of the code on target address, this needs assembly
length := extcodesize(_addr)
}
if(length>0) {
return true;
}
else {
return false;
}
}
//function that is called when transaction target is an address
function transferToAddress(address _to, uint _value, bytes _data) private returns (bool success) {
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = balanceOf(msg.sender).sub(_value);
balances[_to] = balanceOf(_to).add(_value);
Transfer(msg.sender, _to, _value);
ERC223Transfer(msg.sender, _to, _value, _data);
return true;
}
//function that is called when transaction target is a contract
function transferToContract(address _to, uint _value, bytes _data) private returns (bool success) {
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = balanceOf(msg.sender).sub(_value);
balances[_to] = balanceOf(_to).add(_value);
ContractReceiver reciever = ContractReceiver(_to);
reciever.tokenFallback(msg.sender, _value, _data);
Transfer(msg.sender, _to, _value);
ERC223Transfer(msg.sender, _to, _value, _data);
return true;
}
function balanceOf(address _owner) constant returns (uint balance) {
return balances[_owner];
}
} | isContract | function isContract(address _addr) private returns (bool is_contract) {
uint length;
assembly {
//retrieve the size of the code on target address, this needs assembly
length := extcodesize(_addr)
}
if(length>0) {
return true;
}
else {
return false;
}
}
| //assemble the given address bytecode. If bytecode exists then the _addr is a contract. | LineComment | v0.4.25+commit.59dbf8f1 | bzzr://ab9f0fe42d9e16b9e57ac46a758e7fa8f126024174b2d499ea997543c325ce05 | {
"func_code_index": [
1644,
2002
]
} | 9,102 |
|||
GoodGamePlatform | ERC223.sol | 0x3ac655b147b6e2d2ced40126f6c5956e5467a92b | Solidity | ERC223Token | contract ERC223Token is ERC223 {
using SafeMath for uint;
mapping(address => uint) balances;
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
// Function to access name of token .
function name() constant returns (string _name) {
return name;
}
// Function to access symbol of token .
function symbol() constant returns (string _symbol) {
return symbol;
}
// Function to access decimals of token .
function decimals() constant returns (uint8 _decimals) {
return decimals;
}
// Function to access total supply of tokens .
function totalSupply() constant returns (uint256 _totalSupply) {
return totalSupply;
}
// Function that is called when a user or another contract wants to transfer funds .
function transfer(address _to, uint _value, bytes _data) returns (bool success) {
if(isContract(_to)) {
return transferToContract(_to, _value, _data);
}
else {
return transferToAddress(_to, _value, _data);
}
}
// Standard function transfer similar to ERC20 transfer with no _data .
// Added due to backwards compatibility reasons .
function transfer(address _to, uint _value) returns (bool success) {
//standard function transfer similar to ERC20 transfer with no _data
//added due to backwards compatibility reasons
bytes memory empty;
if(isContract(_to)) {
return transferToContract(_to, _value, empty);
}
else {
return transferToAddress(_to, _value, empty);
}
}
//assemble the given address bytecode. If bytecode exists then the _addr is a contract.
function isContract(address _addr) private returns (bool is_contract) {
uint length;
assembly {
//retrieve the size of the code on target address, this needs assembly
length := extcodesize(_addr)
}
if(length>0) {
return true;
}
else {
return false;
}
}
//function that is called when transaction target is an address
function transferToAddress(address _to, uint _value, bytes _data) private returns (bool success) {
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = balanceOf(msg.sender).sub(_value);
balances[_to] = balanceOf(_to).add(_value);
Transfer(msg.sender, _to, _value);
ERC223Transfer(msg.sender, _to, _value, _data);
return true;
}
//function that is called when transaction target is a contract
function transferToContract(address _to, uint _value, bytes _data) private returns (bool success) {
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = balanceOf(msg.sender).sub(_value);
balances[_to] = balanceOf(_to).add(_value);
ContractReceiver reciever = ContractReceiver(_to);
reciever.tokenFallback(msg.sender, _value, _data);
Transfer(msg.sender, _to, _value);
ERC223Transfer(msg.sender, _to, _value, _data);
return true;
}
function balanceOf(address _owner) constant returns (uint balance) {
return balances[_owner];
}
} | transferToAddress | function transferToAddress(address _to, uint _value, bytes _data) private returns (bool success) {
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = balanceOf(msg.sender).sub(_value);
balances[_to] = balanceOf(_to).add(_value);
Transfer(msg.sender, _to, _value);
ERC223Transfer(msg.sender, _to, _value, _data);
return true;
}
| //function that is called when transaction target is an address | LineComment | v0.4.25+commit.59dbf8f1 | bzzr://ab9f0fe42d9e16b9e57ac46a758e7fa8f126024174b2d499ea997543c325ce05 | {
"func_code_index": [
2070,
2442
]
} | 9,103 |
|||
GoodGamePlatform | ERC223.sol | 0x3ac655b147b6e2d2ced40126f6c5956e5467a92b | Solidity | ERC223Token | contract ERC223Token is ERC223 {
using SafeMath for uint;
mapping(address => uint) balances;
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
// Function to access name of token .
function name() constant returns (string _name) {
return name;
}
// Function to access symbol of token .
function symbol() constant returns (string _symbol) {
return symbol;
}
// Function to access decimals of token .
function decimals() constant returns (uint8 _decimals) {
return decimals;
}
// Function to access total supply of tokens .
function totalSupply() constant returns (uint256 _totalSupply) {
return totalSupply;
}
// Function that is called when a user or another contract wants to transfer funds .
function transfer(address _to, uint _value, bytes _data) returns (bool success) {
if(isContract(_to)) {
return transferToContract(_to, _value, _data);
}
else {
return transferToAddress(_to, _value, _data);
}
}
// Standard function transfer similar to ERC20 transfer with no _data .
// Added due to backwards compatibility reasons .
function transfer(address _to, uint _value) returns (bool success) {
//standard function transfer similar to ERC20 transfer with no _data
//added due to backwards compatibility reasons
bytes memory empty;
if(isContract(_to)) {
return transferToContract(_to, _value, empty);
}
else {
return transferToAddress(_to, _value, empty);
}
}
//assemble the given address bytecode. If bytecode exists then the _addr is a contract.
function isContract(address _addr) private returns (bool is_contract) {
uint length;
assembly {
//retrieve the size of the code on target address, this needs assembly
length := extcodesize(_addr)
}
if(length>0) {
return true;
}
else {
return false;
}
}
//function that is called when transaction target is an address
function transferToAddress(address _to, uint _value, bytes _data) private returns (bool success) {
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = balanceOf(msg.sender).sub(_value);
balances[_to] = balanceOf(_to).add(_value);
Transfer(msg.sender, _to, _value);
ERC223Transfer(msg.sender, _to, _value, _data);
return true;
}
//function that is called when transaction target is a contract
function transferToContract(address _to, uint _value, bytes _data) private returns (bool success) {
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = balanceOf(msg.sender).sub(_value);
balances[_to] = balanceOf(_to).add(_value);
ContractReceiver reciever = ContractReceiver(_to);
reciever.tokenFallback(msg.sender, _value, _data);
Transfer(msg.sender, _to, _value);
ERC223Transfer(msg.sender, _to, _value, _data);
return true;
}
function balanceOf(address _owner) constant returns (uint balance) {
return balances[_owner];
}
} | transferToContract | function transferToContract(address _to, uint _value, bytes _data) private returns (bool success) {
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = balanceOf(msg.sender).sub(_value);
balances[_to] = balanceOf(_to).add(_value);
ContractReceiver reciever = ContractReceiver(_to);
reciever.tokenFallback(msg.sender, _value, _data);
Transfer(msg.sender, _to, _value);
ERC223Transfer(msg.sender, _to, _value, _data);
return true;
}
| //function that is called when transaction target is a contract | LineComment | v0.4.25+commit.59dbf8f1 | bzzr://ab9f0fe42d9e16b9e57ac46a758e7fa8f126024174b2d499ea997543c325ce05 | {
"func_code_index": [
2510,
2993
]
} | 9,104 |
|||
Sav3rToken | erc-payable-token/contracts/token/ERC1363/IERC1363.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | IERC1363 | interface IERC1363 is IERC20, IERC165 {
/*
* Note: the ERC-165 identifier for this interface is 0x4bbee2df.
* 0x4bbee2df ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCallData(address,address,uint256,bytes)'))
*/
/*
* Note: the ERC-165 identifier for this interface is 0xfb9ec8ce.
* 0xfb9ec8ce ===
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCallData(address,uint256,bytes)'))
*/
/**
* @notice Transfer tokens from `msg.sender` to another address and then call `onTransferReceived` on receiver
* @param to address The address which you want to transfer to
* @param value uint256 The amount of tokens to be transferred
* @return true unless throwing
*/
function transferAndCall(address to, uint256 value) external returns (bool);
/**
* @notice Transfer tokens from `msg.sender` to another address and then call `onTransferReceived` on receiver
* @param to address The address which you want to transfer to
* @param value uint256 The amount of tokens to be transferred
* @param data bytes Additional data with no specified format, sent in call to `to`
* @return true unless throwing
*/
function transferAndCallData(address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @notice Transfer tokens from one address to another and then call `onTransferReceived` on receiver
* @param from address The address which you want to send tokens from
* @param to address The address which you want to transfer to
* @param value uint256 The amount of tokens to be transferred
* @param data bytes Additional data with no specified format, sent in call to `to`
* @return true unless throwing
*/
function transferFromAndCallData(address from, address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @notice Approve the passed address to spend the specified amount of tokens on behalf of msg.sender
* and then call `onApprovalReceived` on spender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param spender address The address which will spend the funds
* @param value uint256 The amount of tokens to be spent
*/
function approveAndCall(address spender, uint256 value) external returns (bool);
/**
* @notice Approve the passed address to spend the specified amount of tokens on behalf of msg.sender
* and then call `onApprovalReceived` on spender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param spender address The address which will spend the funds
* @param value uint256 The amount of tokens to be spent
* @param data bytes Additional data with no specified format, sent in call to `spender`
*/
function approveAndCallData(address spender, uint256 value, bytes calldata data) external returns (bool);
} | /**
* @title IERC1363 Interface
* @author Vittorio Minacori (https://github.com/vittominacori)
* @dev Interface for a Payable Token contract as defined in
* https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1363.md
*/ | NatSpecMultiLine | transferAndCall | function transferAndCall(address to, uint256 value) external returns (bool);
| /**
* @notice Transfer tokens from `msg.sender` to another address and then call `onTransferReceived` on receiver
* @param to address The address which you want to transfer to
* @param value uint256 The amount of tokens to be transferred
* @return true unless throwing
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
1014,
1095
]
} | 9,105 |
Sav3rToken | erc-payable-token/contracts/token/ERC1363/IERC1363.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | IERC1363 | interface IERC1363 is IERC20, IERC165 {
/*
* Note: the ERC-165 identifier for this interface is 0x4bbee2df.
* 0x4bbee2df ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCallData(address,address,uint256,bytes)'))
*/
/*
* Note: the ERC-165 identifier for this interface is 0xfb9ec8ce.
* 0xfb9ec8ce ===
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCallData(address,uint256,bytes)'))
*/
/**
* @notice Transfer tokens from `msg.sender` to another address and then call `onTransferReceived` on receiver
* @param to address The address which you want to transfer to
* @param value uint256 The amount of tokens to be transferred
* @return true unless throwing
*/
function transferAndCall(address to, uint256 value) external returns (bool);
/**
* @notice Transfer tokens from `msg.sender` to another address and then call `onTransferReceived` on receiver
* @param to address The address which you want to transfer to
* @param value uint256 The amount of tokens to be transferred
* @param data bytes Additional data with no specified format, sent in call to `to`
* @return true unless throwing
*/
function transferAndCallData(address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @notice Transfer tokens from one address to another and then call `onTransferReceived` on receiver
* @param from address The address which you want to send tokens from
* @param to address The address which you want to transfer to
* @param value uint256 The amount of tokens to be transferred
* @param data bytes Additional data with no specified format, sent in call to `to`
* @return true unless throwing
*/
function transferFromAndCallData(address from, address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @notice Approve the passed address to spend the specified amount of tokens on behalf of msg.sender
* and then call `onApprovalReceived` on spender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param spender address The address which will spend the funds
* @param value uint256 The amount of tokens to be spent
*/
function approveAndCall(address spender, uint256 value) external returns (bool);
/**
* @notice Approve the passed address to spend the specified amount of tokens on behalf of msg.sender
* and then call `onApprovalReceived` on spender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param spender address The address which will spend the funds
* @param value uint256 The amount of tokens to be spent
* @param data bytes Additional data with no specified format, sent in call to `spender`
*/
function approveAndCallData(address spender, uint256 value, bytes calldata data) external returns (bool);
} | /**
* @title IERC1363 Interface
* @author Vittorio Minacori (https://github.com/vittominacori)
* @dev Interface for a Payable Token contract as defined in
* https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1363.md
*/ | NatSpecMultiLine | transferAndCallData | function transferAndCallData(address to, uint256 value, bytes calldata data) external returns (bool);
| /**
* @notice Transfer tokens from `msg.sender` to another address and then call `onTransferReceived` on receiver
* @param to address The address which you want to transfer to
* @param value uint256 The amount of tokens to be transferred
* @param data bytes Additional data with no specified format, sent in call to `to`
* @return true unless throwing
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
1494,
1600
]
} | 9,106 |
Sav3rToken | erc-payable-token/contracts/token/ERC1363/IERC1363.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | IERC1363 | interface IERC1363 is IERC20, IERC165 {
/*
* Note: the ERC-165 identifier for this interface is 0x4bbee2df.
* 0x4bbee2df ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCallData(address,address,uint256,bytes)'))
*/
/*
* Note: the ERC-165 identifier for this interface is 0xfb9ec8ce.
* 0xfb9ec8ce ===
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCallData(address,uint256,bytes)'))
*/
/**
* @notice Transfer tokens from `msg.sender` to another address and then call `onTransferReceived` on receiver
* @param to address The address which you want to transfer to
* @param value uint256 The amount of tokens to be transferred
* @return true unless throwing
*/
function transferAndCall(address to, uint256 value) external returns (bool);
/**
* @notice Transfer tokens from `msg.sender` to another address and then call `onTransferReceived` on receiver
* @param to address The address which you want to transfer to
* @param value uint256 The amount of tokens to be transferred
* @param data bytes Additional data with no specified format, sent in call to `to`
* @return true unless throwing
*/
function transferAndCallData(address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @notice Transfer tokens from one address to another and then call `onTransferReceived` on receiver
* @param from address The address which you want to send tokens from
* @param to address The address which you want to transfer to
* @param value uint256 The amount of tokens to be transferred
* @param data bytes Additional data with no specified format, sent in call to `to`
* @return true unless throwing
*/
function transferFromAndCallData(address from, address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @notice Approve the passed address to spend the specified amount of tokens on behalf of msg.sender
* and then call `onApprovalReceived` on spender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param spender address The address which will spend the funds
* @param value uint256 The amount of tokens to be spent
*/
function approveAndCall(address spender, uint256 value) external returns (bool);
/**
* @notice Approve the passed address to spend the specified amount of tokens on behalf of msg.sender
* and then call `onApprovalReceived` on spender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param spender address The address which will spend the funds
* @param value uint256 The amount of tokens to be spent
* @param data bytes Additional data with no specified format, sent in call to `spender`
*/
function approveAndCallData(address spender, uint256 value, bytes calldata data) external returns (bool);
} | /**
* @title IERC1363 Interface
* @author Vittorio Minacori (https://github.com/vittominacori)
* @dev Interface for a Payable Token contract as defined in
* https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1363.md
*/ | NatSpecMultiLine | transferFromAndCallData | function transferFromAndCallData(address from, address to, uint256 value, bytes calldata data) external returns (bool);
| /**
* @notice Transfer tokens from one address to another and then call `onTransferReceived` on receiver
* @param from address The address which you want to send tokens from
* @param to address The address which you want to transfer to
* @param value uint256 The amount of tokens to be transferred
* @param data bytes Additional data with no specified format, sent in call to `to`
* @return true unless throwing
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
2065,
2189
]
} | 9,107 |
Sav3rToken | erc-payable-token/contracts/token/ERC1363/IERC1363.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | IERC1363 | interface IERC1363 is IERC20, IERC165 {
/*
* Note: the ERC-165 identifier for this interface is 0x4bbee2df.
* 0x4bbee2df ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCallData(address,address,uint256,bytes)'))
*/
/*
* Note: the ERC-165 identifier for this interface is 0xfb9ec8ce.
* 0xfb9ec8ce ===
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCallData(address,uint256,bytes)'))
*/
/**
* @notice Transfer tokens from `msg.sender` to another address and then call `onTransferReceived` on receiver
* @param to address The address which you want to transfer to
* @param value uint256 The amount of tokens to be transferred
* @return true unless throwing
*/
function transferAndCall(address to, uint256 value) external returns (bool);
/**
* @notice Transfer tokens from `msg.sender` to another address and then call `onTransferReceived` on receiver
* @param to address The address which you want to transfer to
* @param value uint256 The amount of tokens to be transferred
* @param data bytes Additional data with no specified format, sent in call to `to`
* @return true unless throwing
*/
function transferAndCallData(address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @notice Transfer tokens from one address to another and then call `onTransferReceived` on receiver
* @param from address The address which you want to send tokens from
* @param to address The address which you want to transfer to
* @param value uint256 The amount of tokens to be transferred
* @param data bytes Additional data with no specified format, sent in call to `to`
* @return true unless throwing
*/
function transferFromAndCallData(address from, address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @notice Approve the passed address to spend the specified amount of tokens on behalf of msg.sender
* and then call `onApprovalReceived` on spender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param spender address The address which will spend the funds
* @param value uint256 The amount of tokens to be spent
*/
function approveAndCall(address spender, uint256 value) external returns (bool);
/**
* @notice Approve the passed address to spend the specified amount of tokens on behalf of msg.sender
* and then call `onApprovalReceived` on spender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param spender address The address which will spend the funds
* @param value uint256 The amount of tokens to be spent
* @param data bytes Additional data with no specified format, sent in call to `spender`
*/
function approveAndCallData(address spender, uint256 value, bytes calldata data) external returns (bool);
} | /**
* @title IERC1363 Interface
* @author Vittorio Minacori (https://github.com/vittominacori)
* @dev Interface for a Payable Token contract as defined in
* https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1363.md
*/ | NatSpecMultiLine | approveAndCall | function approveAndCall(address spender, uint256 value) external returns (bool);
| /**
* @notice Approve the passed address to spend the specified amount of tokens on behalf of msg.sender
* and then call `onApprovalReceived` on spender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param spender address The address which will spend the funds
* @param value uint256 The amount of tokens to be spent
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
2902,
2987
]
} | 9,108 |
Sav3rToken | erc-payable-token/contracts/token/ERC1363/IERC1363.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | IERC1363 | interface IERC1363 is IERC20, IERC165 {
/*
* Note: the ERC-165 identifier for this interface is 0x4bbee2df.
* 0x4bbee2df ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCallData(address,address,uint256,bytes)'))
*/
/*
* Note: the ERC-165 identifier for this interface is 0xfb9ec8ce.
* 0xfb9ec8ce ===
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCallData(address,uint256,bytes)'))
*/
/**
* @notice Transfer tokens from `msg.sender` to another address and then call `onTransferReceived` on receiver
* @param to address The address which you want to transfer to
* @param value uint256 The amount of tokens to be transferred
* @return true unless throwing
*/
function transferAndCall(address to, uint256 value) external returns (bool);
/**
* @notice Transfer tokens from `msg.sender` to another address and then call `onTransferReceived` on receiver
* @param to address The address which you want to transfer to
* @param value uint256 The amount of tokens to be transferred
* @param data bytes Additional data with no specified format, sent in call to `to`
* @return true unless throwing
*/
function transferAndCallData(address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @notice Transfer tokens from one address to another and then call `onTransferReceived` on receiver
* @param from address The address which you want to send tokens from
* @param to address The address which you want to transfer to
* @param value uint256 The amount of tokens to be transferred
* @param data bytes Additional data with no specified format, sent in call to `to`
* @return true unless throwing
*/
function transferFromAndCallData(address from, address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @notice Approve the passed address to spend the specified amount of tokens on behalf of msg.sender
* and then call `onApprovalReceived` on spender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param spender address The address which will spend the funds
* @param value uint256 The amount of tokens to be spent
*/
function approveAndCall(address spender, uint256 value) external returns (bool);
/**
* @notice Approve the passed address to spend the specified amount of tokens on behalf of msg.sender
* and then call `onApprovalReceived` on spender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param spender address The address which will spend the funds
* @param value uint256 The amount of tokens to be spent
* @param data bytes Additional data with no specified format, sent in call to `spender`
*/
function approveAndCallData(address spender, uint256 value, bytes calldata data) external returns (bool);
} | /**
* @title IERC1363 Interface
* @author Vittorio Minacori (https://github.com/vittominacori)
* @dev Interface for a Payable Token contract as defined in
* https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1363.md
*/ | NatSpecMultiLine | approveAndCallData | function approveAndCallData(address spender, uint256 value, bytes calldata data) external returns (bool);
| /**
* @notice Approve the passed address to spend the specified amount of tokens on behalf of msg.sender
* and then call `onApprovalReceived` on spender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param spender address The address which will spend the funds
* @param value uint256 The amount of tokens to be spent
* @param data bytes Additional data with no specified format, sent in call to `spender`
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
3794,
3904
]
} | 9,109 |
Sav3rToken | erc-payable-token/contracts/token/ERC1363/IERC1363.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | IERC1363Receiver | interface IERC1363Receiver {
/*
* Note: the ERC-165 identifier for this interface is 0x88a7ca5c.
* 0x88a7ca5c === bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))
*/
/**
* @notice Handle the receipt of ERC1363 tokens
* @dev Any ERC1363 smart contract calls this function on the recipient
* after a `transfer` or a `transferFrom`. This function MAY throw to revert and reject the
* transfer. Return of other than the magic value MUST result in the
* transaction being reverted.
* Note: the token contract address is always the message sender.
* @param operator address The address which called `transferAndCall` or `transferFromAndCall` function
* @param from address The address which are token transferred from
* @param value uint256 The amount of tokens transferred
* @param data bytes Additional data with no specified format
* @return `bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))`
* unless throwing
*/
function onTransferReceived(address operator, address from, uint256 value, bytes calldata data) external returns (bytes4); // solhint-disable-line max-line-length
} | /**
* @title IERC1363Receiver Interface
* @author Vittorio Minacori (https://github.com/vittominacori)
* @dev Interface for any contract that wants to support transferAndCall or transferFromAndCall
* from ERC1363 token contracts as defined in
* https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1363.md
*/ | NatSpecMultiLine | onTransferReceived | function onTransferReceived(address operator, address from, uint256 value, bytes calldata data) external returns (bytes4); // solhint-disable-line max-line-length
| /**
* @notice Handle the receipt of ERC1363 tokens
* @dev Any ERC1363 smart contract calls this function on the recipient
* after a `transfer` or a `transferFrom`. This function MAY throw to revert and reject the
* transfer. Return of other than the magic value MUST result in the
* transaction being reverted.
* Note: the token contract address is always the message sender.
* @param operator address The address which called `transferAndCall` or `transferFromAndCall` function
* @param from address The address which are token transferred from
* @param value uint256 The amount of tokens transferred
* @param data bytes Additional data with no specified format
* @return `bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))`
* unless throwing
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
1065,
1233
]
} | 9,110 |
Sav3rToken | erc-payable-token/contracts/token/ERC1363/IERC1363.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | IERC1363Spender | interface IERC1363Spender {
/*
* Note: the ERC-165 identifier for this interface is 0x7b04a2d0.
* 0x7b04a2d0 === bytes4(keccak256("onApprovalReceived(address,uint256,bytes)"))
*/
/**
* @notice Handle the approval of ERC1363 tokens
* @dev Any ERC1363 smart contract calls this function on the recipient
* after an `approve`. This function MAY throw to revert and reject the
* approval. Return of other than the magic value MUST result in the
* transaction being reverted.
* Note: the token contract address is always the message sender.
* @param owner address The address which called `approveAndCall` function
* @param value uint256 The amount of tokens to be spent
* @param data bytes Additional data with no specified format
* @return `bytes4(keccak256("onApprovalReceived(address,uint256,bytes)"))`
* unless throwing
*/
function onApprovalReceived(address owner, uint256 value, bytes calldata data) external returns (bytes4);
} | /**
* @title IERC1363Spender Interface
* @author Vittorio Minacori (https://github.com/vittominacori)
* @dev Interface for any contract that wants to support approveAndCall
* from ERC1363 token contracts as defined in
* https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1363.md
*/ | NatSpecMultiLine | onApprovalReceived | function onApprovalReceived(address owner, uint256 value, bytes calldata data) external returns (bytes4);
| /**
* @notice Handle the approval of ERC1363 tokens
* @dev Any ERC1363 smart contract calls this function on the recipient
* after an `approve`. This function MAY throw to revert and reject the
* approval. Return of other than the magic value MUST result in the
* transaction being reverted.
* Note: the token contract address is always the message sender.
* @param owner address The address which called `approveAndCall` function
* @param value uint256 The amount of tokens to be spent
* @param data bytes Additional data with no specified format
* @return `bytes4(keccak256("onApprovalReceived(address,uint256,bytes)"))`
* unless throwing
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
927,
1037
]
} | 9,111 |
Sav3rToken | erc-payable-token/contracts/token/ERC1363/IERC1363.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | ERC165Checker | library ERC165Checker {
// As per the EIP-165 spec, no interface should ever match 0xffffffff
bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff;
/*
* bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7
*/
bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7;
/**
* @dev Returns true if `account` supports the {IERC165} interface,
*/
function supportsERC165(address account) internal view returns (bool) {
// Any contract that implements ERC165 must explicitly indicate support of
// InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid
return _supportsERC165Interface(account, _INTERFACE_ID_ERC165) &&
!_supportsERC165Interface(account, _INTERFACE_ID_INVALID);
}
/**
* @dev Returns true if `account` supports the interface defined by
* `interfaceId`. Support for {IERC165} itself is queried automatically.
*
* See {IERC165-supportsInterface}.
*/
function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) {
// query support of both ERC165 as per the spec and support of _interfaceId
return supportsERC165(account) &&
_supportsERC165Interface(account, interfaceId);
}
/**
* @dev Returns true if `account` supports all the interfaces defined in
* `interfaceIds`. Support for {IERC165} itself is queried automatically.
*
* Batch-querying can lead to gas savings by skipping repeated checks for
* {IERC165} support.
*
* See {IERC165-supportsInterface}.
*/
function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) {
// query support of ERC165 itself
if (!supportsERC165(account)) {
return false;
}
// query support of each interface in _interfaceIds
for (uint256 i = 0; i < interfaceIds.length; i++) {
if (!_supportsERC165Interface(account, interfaceIds[i])) {
return false;
}
}
// all interfaces supported
return true;
}
/**
* @notice Query if a contract implements an interface, does not check ERC165 support
* @param account The address of the contract to query for support of an interface
* @param interfaceId The interface identifier, as specified in ERC-165
* @return true if the contract at account indicates support of the interface with
* identifier interfaceId, false otherwise
* @dev Assumes that account contains a contract that supports ERC165, otherwise
* the behavior of this method is undefined. This precondition can be checked
* with {supportsERC165}.
* Interface identification is specified in ERC-165.
*/
function _supportsERC165Interface(address account, bytes4 interfaceId) private view returns (bool) {
// success determines whether the staticcall succeeded and result determines
// whether the contract at account indicates support of _interfaceId
(bool success, bool result) = _callERC165SupportsInterface(account, interfaceId);
return (success && result);
}
/**
* @notice Calls the function with selector 0x01ffc9a7 (ERC165) and suppresses throw
* @param account The address of the contract to query for support of an interface
* @param interfaceId The interface identifier, as specified in ERC-165
* @return success true if the STATICCALL succeeded, false otherwise
* @return result true if the STATICCALL succeeded and the contract at account
* indicates support of the interface with identifier interfaceId, false otherwise
*/
function _callERC165SupportsInterface(address account, bytes4 interfaceId)
private
view
returns (bool, bool)
{
bytes memory encodedParams = abi.encodeWithSelector(_INTERFACE_ID_ERC165, interfaceId);
(bool success, bytes memory result) = account.staticcall{ gas: 30000 }(encodedParams);
if (result.length < 32) return (false, false);
return (success, abi.decode(result, (bool)));
}
} | /**
* @dev Library used to query support of an interface declared via {IERC165}.
*
* Note that these functions return the actual result of the query: they do not
* `revert` if an interface is not supported. It is up to the caller to decide
* what to do in these cases.
*/ | NatSpecMultiLine | supportsERC165 | function supportsERC165(address account) internal view returns (bool) {
// Any contract that implements ERC165 must explicitly indicate support of
// InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid
return _supportsERC165Interface(account, _INTERFACE_ID_ERC165) &&
!_supportsERC165Interface(account, _INTERFACE_ID_INVALID);
}
| /**
* @dev Returns true if `account` supports the {IERC165} interface,
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
410,
814
]
} | 9,112 |
Sav3rToken | erc-payable-token/contracts/token/ERC1363/IERC1363.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | ERC165Checker | library ERC165Checker {
// As per the EIP-165 spec, no interface should ever match 0xffffffff
bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff;
/*
* bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7
*/
bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7;
/**
* @dev Returns true if `account` supports the {IERC165} interface,
*/
function supportsERC165(address account) internal view returns (bool) {
// Any contract that implements ERC165 must explicitly indicate support of
// InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid
return _supportsERC165Interface(account, _INTERFACE_ID_ERC165) &&
!_supportsERC165Interface(account, _INTERFACE_ID_INVALID);
}
/**
* @dev Returns true if `account` supports the interface defined by
* `interfaceId`. Support for {IERC165} itself is queried automatically.
*
* See {IERC165-supportsInterface}.
*/
function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) {
// query support of both ERC165 as per the spec and support of _interfaceId
return supportsERC165(account) &&
_supportsERC165Interface(account, interfaceId);
}
/**
* @dev Returns true if `account` supports all the interfaces defined in
* `interfaceIds`. Support for {IERC165} itself is queried automatically.
*
* Batch-querying can lead to gas savings by skipping repeated checks for
* {IERC165} support.
*
* See {IERC165-supportsInterface}.
*/
function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) {
// query support of ERC165 itself
if (!supportsERC165(account)) {
return false;
}
// query support of each interface in _interfaceIds
for (uint256 i = 0; i < interfaceIds.length; i++) {
if (!_supportsERC165Interface(account, interfaceIds[i])) {
return false;
}
}
// all interfaces supported
return true;
}
/**
* @notice Query if a contract implements an interface, does not check ERC165 support
* @param account The address of the contract to query for support of an interface
* @param interfaceId The interface identifier, as specified in ERC-165
* @return true if the contract at account indicates support of the interface with
* identifier interfaceId, false otherwise
* @dev Assumes that account contains a contract that supports ERC165, otherwise
* the behavior of this method is undefined. This precondition can be checked
* with {supportsERC165}.
* Interface identification is specified in ERC-165.
*/
function _supportsERC165Interface(address account, bytes4 interfaceId) private view returns (bool) {
// success determines whether the staticcall succeeded and result determines
// whether the contract at account indicates support of _interfaceId
(bool success, bool result) = _callERC165SupportsInterface(account, interfaceId);
return (success && result);
}
/**
* @notice Calls the function with selector 0x01ffc9a7 (ERC165) and suppresses throw
* @param account The address of the contract to query for support of an interface
* @param interfaceId The interface identifier, as specified in ERC-165
* @return success true if the STATICCALL succeeded, false otherwise
* @return result true if the STATICCALL succeeded and the contract at account
* indicates support of the interface with identifier interfaceId, false otherwise
*/
function _callERC165SupportsInterface(address account, bytes4 interfaceId)
private
view
returns (bool, bool)
{
bytes memory encodedParams = abi.encodeWithSelector(_INTERFACE_ID_ERC165, interfaceId);
(bool success, bytes memory result) = account.staticcall{ gas: 30000 }(encodedParams);
if (result.length < 32) return (false, false);
return (success, abi.decode(result, (bool)));
}
} | /**
* @dev Library used to query support of an interface declared via {IERC165}.
*
* Note that these functions return the actual result of the query: they do not
* `revert` if an interface is not supported. It is up to the caller to decide
* what to do in these cases.
*/ | NatSpecMultiLine | supportsInterface | function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) {
// query support of both ERC165 as per the spec and support of _interfaceId
return supportsERC165(account) &&
_supportsERC165Interface(account, interfaceId);
}
| /**
* @dev Returns true if `account` supports the interface defined by
* `interfaceId`. Support for {IERC165} itself is queried automatically.
*
* See {IERC165-supportsInterface}.
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
1035,
1330
]
} | 9,113 |
Sav3rToken | erc-payable-token/contracts/token/ERC1363/IERC1363.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | ERC165Checker | library ERC165Checker {
// As per the EIP-165 spec, no interface should ever match 0xffffffff
bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff;
/*
* bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7
*/
bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7;
/**
* @dev Returns true if `account` supports the {IERC165} interface,
*/
function supportsERC165(address account) internal view returns (bool) {
// Any contract that implements ERC165 must explicitly indicate support of
// InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid
return _supportsERC165Interface(account, _INTERFACE_ID_ERC165) &&
!_supportsERC165Interface(account, _INTERFACE_ID_INVALID);
}
/**
* @dev Returns true if `account` supports the interface defined by
* `interfaceId`. Support for {IERC165} itself is queried automatically.
*
* See {IERC165-supportsInterface}.
*/
function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) {
// query support of both ERC165 as per the spec and support of _interfaceId
return supportsERC165(account) &&
_supportsERC165Interface(account, interfaceId);
}
/**
* @dev Returns true if `account` supports all the interfaces defined in
* `interfaceIds`. Support for {IERC165} itself is queried automatically.
*
* Batch-querying can lead to gas savings by skipping repeated checks for
* {IERC165} support.
*
* See {IERC165-supportsInterface}.
*/
function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) {
// query support of ERC165 itself
if (!supportsERC165(account)) {
return false;
}
// query support of each interface in _interfaceIds
for (uint256 i = 0; i < interfaceIds.length; i++) {
if (!_supportsERC165Interface(account, interfaceIds[i])) {
return false;
}
}
// all interfaces supported
return true;
}
/**
* @notice Query if a contract implements an interface, does not check ERC165 support
* @param account The address of the contract to query for support of an interface
* @param interfaceId The interface identifier, as specified in ERC-165
* @return true if the contract at account indicates support of the interface with
* identifier interfaceId, false otherwise
* @dev Assumes that account contains a contract that supports ERC165, otherwise
* the behavior of this method is undefined. This precondition can be checked
* with {supportsERC165}.
* Interface identification is specified in ERC-165.
*/
function _supportsERC165Interface(address account, bytes4 interfaceId) private view returns (bool) {
// success determines whether the staticcall succeeded and result determines
// whether the contract at account indicates support of _interfaceId
(bool success, bool result) = _callERC165SupportsInterface(account, interfaceId);
return (success && result);
}
/**
* @notice Calls the function with selector 0x01ffc9a7 (ERC165) and suppresses throw
* @param account The address of the contract to query for support of an interface
* @param interfaceId The interface identifier, as specified in ERC-165
* @return success true if the STATICCALL succeeded, false otherwise
* @return result true if the STATICCALL succeeded and the contract at account
* indicates support of the interface with identifier interfaceId, false otherwise
*/
function _callERC165SupportsInterface(address account, bytes4 interfaceId)
private
view
returns (bool, bool)
{
bytes memory encodedParams = abi.encodeWithSelector(_INTERFACE_ID_ERC165, interfaceId);
(bool success, bytes memory result) = account.staticcall{ gas: 30000 }(encodedParams);
if (result.length < 32) return (false, false);
return (success, abi.decode(result, (bool)));
}
} | /**
* @dev Library used to query support of an interface declared via {IERC165}.
*
* Note that these functions return the actual result of the query: they do not
* `revert` if an interface is not supported. It is up to the caller to decide
* what to do in these cases.
*/ | NatSpecMultiLine | supportsAllInterfaces | function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) {
// query support of ERC165 itself
if (!supportsERC165(account)) {
return false;
}
// query support of each interface in _interfaceIds
for (uint256 i = 0; i < interfaceIds.length; i++) {
if (!_supportsERC165Interface(account, interfaceIds[i])) {
return false;
}
}
// all interfaces supported
return true;
}
| /**
* @dev Returns true if `account` supports all the interfaces defined in
* `interfaceIds`. Support for {IERC165} itself is queried automatically.
*
* Batch-querying can lead to gas savings by skipping repeated checks for
* {IERC165} support.
*
* See {IERC165-supportsInterface}.
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
1671,
2227
]
} | 9,114 |
Sav3rToken | erc-payable-token/contracts/token/ERC1363/IERC1363.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | ERC165Checker | library ERC165Checker {
// As per the EIP-165 spec, no interface should ever match 0xffffffff
bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff;
/*
* bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7
*/
bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7;
/**
* @dev Returns true if `account` supports the {IERC165} interface,
*/
function supportsERC165(address account) internal view returns (bool) {
// Any contract that implements ERC165 must explicitly indicate support of
// InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid
return _supportsERC165Interface(account, _INTERFACE_ID_ERC165) &&
!_supportsERC165Interface(account, _INTERFACE_ID_INVALID);
}
/**
* @dev Returns true if `account` supports the interface defined by
* `interfaceId`. Support for {IERC165} itself is queried automatically.
*
* See {IERC165-supportsInterface}.
*/
function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) {
// query support of both ERC165 as per the spec and support of _interfaceId
return supportsERC165(account) &&
_supportsERC165Interface(account, interfaceId);
}
/**
* @dev Returns true if `account` supports all the interfaces defined in
* `interfaceIds`. Support for {IERC165} itself is queried automatically.
*
* Batch-querying can lead to gas savings by skipping repeated checks for
* {IERC165} support.
*
* See {IERC165-supportsInterface}.
*/
function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) {
// query support of ERC165 itself
if (!supportsERC165(account)) {
return false;
}
// query support of each interface in _interfaceIds
for (uint256 i = 0; i < interfaceIds.length; i++) {
if (!_supportsERC165Interface(account, interfaceIds[i])) {
return false;
}
}
// all interfaces supported
return true;
}
/**
* @notice Query if a contract implements an interface, does not check ERC165 support
* @param account The address of the contract to query for support of an interface
* @param interfaceId The interface identifier, as specified in ERC-165
* @return true if the contract at account indicates support of the interface with
* identifier interfaceId, false otherwise
* @dev Assumes that account contains a contract that supports ERC165, otherwise
* the behavior of this method is undefined. This precondition can be checked
* with {supportsERC165}.
* Interface identification is specified in ERC-165.
*/
function _supportsERC165Interface(address account, bytes4 interfaceId) private view returns (bool) {
// success determines whether the staticcall succeeded and result determines
// whether the contract at account indicates support of _interfaceId
(bool success, bool result) = _callERC165SupportsInterface(account, interfaceId);
return (success && result);
}
/**
* @notice Calls the function with selector 0x01ffc9a7 (ERC165) and suppresses throw
* @param account The address of the contract to query for support of an interface
* @param interfaceId The interface identifier, as specified in ERC-165
* @return success true if the STATICCALL succeeded, false otherwise
* @return result true if the STATICCALL succeeded and the contract at account
* indicates support of the interface with identifier interfaceId, false otherwise
*/
function _callERC165SupportsInterface(address account, bytes4 interfaceId)
private
view
returns (bool, bool)
{
bytes memory encodedParams = abi.encodeWithSelector(_INTERFACE_ID_ERC165, interfaceId);
(bool success, bytes memory result) = account.staticcall{ gas: 30000 }(encodedParams);
if (result.length < 32) return (false, false);
return (success, abi.decode(result, (bool)));
}
} | /**
* @dev Library used to query support of an interface declared via {IERC165}.
*
* Note that these functions return the actual result of the query: they do not
* `revert` if an interface is not supported. It is up to the caller to decide
* what to do in these cases.
*/ | NatSpecMultiLine | _supportsERC165Interface | function _supportsERC165Interface(address account, bytes4 interfaceId) private view returns (bool) {
// success determines whether the staticcall succeeded and result determines
// whether the contract at account indicates support of _interfaceId
(bool success, bool result) = _callERC165SupportsInterface(account, interfaceId);
return (success && result);
}
| /**
* @notice Query if a contract implements an interface, does not check ERC165 support
* @param account The address of the contract to query for support of an interface
* @param interfaceId The interface identifier, as specified in ERC-165
* @return true if the contract at account indicates support of the interface with
* identifier interfaceId, false otherwise
* @dev Assumes that account contains a contract that supports ERC165, otherwise
* the behavior of this method is undefined. This precondition can be checked
* with {supportsERC165}.
* Interface identification is specified in ERC-165.
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
2898,
3304
]
} | 9,115 |
Sav3rToken | erc-payable-token/contracts/token/ERC1363/IERC1363.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | ERC165Checker | library ERC165Checker {
// As per the EIP-165 spec, no interface should ever match 0xffffffff
bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff;
/*
* bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7
*/
bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7;
/**
* @dev Returns true if `account` supports the {IERC165} interface,
*/
function supportsERC165(address account) internal view returns (bool) {
// Any contract that implements ERC165 must explicitly indicate support of
// InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid
return _supportsERC165Interface(account, _INTERFACE_ID_ERC165) &&
!_supportsERC165Interface(account, _INTERFACE_ID_INVALID);
}
/**
* @dev Returns true if `account` supports the interface defined by
* `interfaceId`. Support for {IERC165} itself is queried automatically.
*
* See {IERC165-supportsInterface}.
*/
function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) {
// query support of both ERC165 as per the spec and support of _interfaceId
return supportsERC165(account) &&
_supportsERC165Interface(account, interfaceId);
}
/**
* @dev Returns true if `account` supports all the interfaces defined in
* `interfaceIds`. Support for {IERC165} itself is queried automatically.
*
* Batch-querying can lead to gas savings by skipping repeated checks for
* {IERC165} support.
*
* See {IERC165-supportsInterface}.
*/
function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) {
// query support of ERC165 itself
if (!supportsERC165(account)) {
return false;
}
// query support of each interface in _interfaceIds
for (uint256 i = 0; i < interfaceIds.length; i++) {
if (!_supportsERC165Interface(account, interfaceIds[i])) {
return false;
}
}
// all interfaces supported
return true;
}
/**
* @notice Query if a contract implements an interface, does not check ERC165 support
* @param account The address of the contract to query for support of an interface
* @param interfaceId The interface identifier, as specified in ERC-165
* @return true if the contract at account indicates support of the interface with
* identifier interfaceId, false otherwise
* @dev Assumes that account contains a contract that supports ERC165, otherwise
* the behavior of this method is undefined. This precondition can be checked
* with {supportsERC165}.
* Interface identification is specified in ERC-165.
*/
function _supportsERC165Interface(address account, bytes4 interfaceId) private view returns (bool) {
// success determines whether the staticcall succeeded and result determines
// whether the contract at account indicates support of _interfaceId
(bool success, bool result) = _callERC165SupportsInterface(account, interfaceId);
return (success && result);
}
/**
* @notice Calls the function with selector 0x01ffc9a7 (ERC165) and suppresses throw
* @param account The address of the contract to query for support of an interface
* @param interfaceId The interface identifier, as specified in ERC-165
* @return success true if the STATICCALL succeeded, false otherwise
* @return result true if the STATICCALL succeeded and the contract at account
* indicates support of the interface with identifier interfaceId, false otherwise
*/
function _callERC165SupportsInterface(address account, bytes4 interfaceId)
private
view
returns (bool, bool)
{
bytes memory encodedParams = abi.encodeWithSelector(_INTERFACE_ID_ERC165, interfaceId);
(bool success, bytes memory result) = account.staticcall{ gas: 30000 }(encodedParams);
if (result.length < 32) return (false, false);
return (success, abi.decode(result, (bool)));
}
} | /**
* @dev Library used to query support of an interface declared via {IERC165}.
*
* Note that these functions return the actual result of the query: they do not
* `revert` if an interface is not supported. It is up to the caller to decide
* what to do in these cases.
*/ | NatSpecMultiLine | _callERC165SupportsInterface | function _callERC165SupportsInterface(address account, bytes4 interfaceId)
private
view
returns (bool, bool)
{
bytes memory encodedParams = abi.encodeWithSelector(_INTERFACE_ID_ERC165, interfaceId);
(bool success, bytes memory result) = account.staticcall{ gas: 30000 }(encodedParams);
if (result.length < 32) return (false, false);
return (success, abi.decode(result, (bool)));
}
| /**
* @notice Calls the function with selector 0x01ffc9a7 (ERC165) and suppresses throw
* @param account The address of the contract to query for support of an interface
* @param interfaceId The interface identifier, as specified in ERC-165
* @return success true if the STATICCALL succeeded, false otherwise
* @return result true if the STATICCALL succeeded and the contract at account
* indicates support of the interface with identifier interfaceId, false otherwise
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
3826,
4284
]
} | 9,116 |
Sav3rToken | erc-payable-token/contracts/token/ERC1363/IERC1363.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | ERC165 | contract ERC165 is IERC165 {
/*
* bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7
*/
bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7;
/**
* @dev Mapping of interface ids to whether or not it's supported.
*/
mapping(bytes4 => bool) private _supportedInterfaces;
constructor () internal {
// Derived contracts need only register support for their own interfaces,
// we register support for ERC165 itself here
_registerInterface(_INTERFACE_ID_ERC165);
}
/**
* @dev See {IERC165-supportsInterface}.
*
* Time complexity O(1), guaranteed to always use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) public view override returns (bool) {
return _supportedInterfaces[interfaceId];
}
/**
* @dev Registers the contract as an implementer of the interface defined by
* `interfaceId`. Support of the actual ERC165 interface is automatic and
* registering its interface id is not required.
*
* See {IERC165-supportsInterface}.
*
* Requirements:
*
* - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`).
*/
function _registerInterface(bytes4 interfaceId) internal virtual {
require(interfaceId != 0xffffffff, "ERC165: invalid interface id");
_supportedInterfaces[interfaceId] = true;
}
} | /**
* @dev Implementation of the {IERC165} interface.
*
* Contracts may inherit from this and call {_registerInterface} to declare
* their support of an interface.
*/ | NatSpecMultiLine | supportsInterface | function supportsInterface(bytes4 interfaceId) public view override returns (bool) {
return _supportedInterfaces[interfaceId];
}
| /**
* @dev See {IERC165-supportsInterface}.
*
* Time complexity O(1), guaranteed to always use less than 30 000 gas.
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
711,
858
]
} | 9,117 |
Sav3rToken | erc-payable-token/contracts/token/ERC1363/IERC1363.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | ERC165 | contract ERC165 is IERC165 {
/*
* bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7
*/
bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7;
/**
* @dev Mapping of interface ids to whether or not it's supported.
*/
mapping(bytes4 => bool) private _supportedInterfaces;
constructor () internal {
// Derived contracts need only register support for their own interfaces,
// we register support for ERC165 itself here
_registerInterface(_INTERFACE_ID_ERC165);
}
/**
* @dev See {IERC165-supportsInterface}.
*
* Time complexity O(1), guaranteed to always use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) public view override returns (bool) {
return _supportedInterfaces[interfaceId];
}
/**
* @dev Registers the contract as an implementer of the interface defined by
* `interfaceId`. Support of the actual ERC165 interface is automatic and
* registering its interface id is not required.
*
* See {IERC165-supportsInterface}.
*
* Requirements:
*
* - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`).
*/
function _registerInterface(bytes4 interfaceId) internal virtual {
require(interfaceId != 0xffffffff, "ERC165: invalid interface id");
_supportedInterfaces[interfaceId] = true;
}
} | /**
* @dev Implementation of the {IERC165} interface.
*
* Contracts may inherit from this and call {_registerInterface} to declare
* their support of an interface.
*/ | NatSpecMultiLine | _registerInterface | function _registerInterface(bytes4 interfaceId) internal virtual {
require(interfaceId != 0xffffffff, "ERC165: invalid interface id");
_supportedInterfaces[interfaceId] = true;
}
| /**
* @dev Registers the contract as an implementer of the interface defined by
* `interfaceId`. Support of the actual ERC165 interface is automatic and
* registering its interface id is not required.
*
* See {IERC165-supportsInterface}.
*
* Requirements:
*
* - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`).
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
1260,
1466
]
} | 9,118 |
Sav3rToken | erc-payable-token/contracts/token/ERC1363/IERC1363.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | ERC1363 | contract ERC1363 is ERC20, IERC1363, ERC165 {
using Address for address;
/*
* Note: the ERC-165 identifier for this interface is 0x4bbee2df.
* 0x4bbee2df ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)'))
*/
bytes4 internal constant _INTERFACE_ID_ERC1363_TRANSFER = 0x4bbee2df;
/*
* Note: the ERC-165 identifier for this interface is 0xfb9ec8ce.
* 0xfb9ec8ce ===
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
bytes4 internal constant _INTERFACE_ID_ERC1363_APPROVE = 0xfb9ec8ce;
// Equals to `bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))`
// which can be also obtained as `IERC1363Receiver(0).onTransferReceived.selector`
bytes4 private constant _ERC1363_RECEIVED = 0x88a7ca5c;
// Equals to `bytes4(keccak256("onApprovalReceived(address,uint256,bytes)"))`
// which can be also obtained as `IERC1363Spender(0).onApprovalReceived.selector`
bytes4 private constant _ERC1363_APPROVED = 0x7b04a2d0;
/**
* @param name Name of the token
* @param symbol A symbol to be used as ticker
*/
constructor (
string memory name,
string memory symbol
) public payable ERC20(name, symbol) {
// register the supported interfaces to conform to ERC1363 via ERC165
_registerInterface(_INTERFACE_ID_ERC1363_TRANSFER);
_registerInterface(_INTERFACE_ID_ERC1363_APPROVE);
}
/**
* @dev Transfer tokens to a specified address and then execute a callback on recipient.
* @param to The address to transfer to.
* @param value The amount to be transferred.
* @return A boolean that indicates if the operation was successful.
*/
function transferAndCall(address to, uint256 value) public override returns (bool) {
return transferAndCallData(to, value, "");
}
/**
* @dev Transfer tokens to a specified address and then execute a callback on recipient.
* @param to The address to transfer to
* @param value The amount to be transferred
* @param data Additional data with no specified format
* @return A boolean that indicates if the operation was successful.
*/
function transferAndCallData(address to, uint256 value, bytes memory data) public override returns (bool) {
transfer(to, value);
require(_checkAndCallTransfer(_msgSender(), to, value, data), "ERC1363: _checkAndCallTransfer reverts");
return true;
}
/**
* @dev Transfer tokens from one address to another and then execute a callback on recipient.
* @param from The address which you want to send tokens from
* @param to The address which you want to transfer to
* @param value The amount of tokens to be transferred
* @param data Additional data with no specified format
* @return A boolean that indicates if the operation was successful.
*/
function transferFromAndCallData(address from, address to, uint256 value, bytes memory data) public override returns (bool) {
transferFrom(from, to, value);
require(_checkAndCallTransfer(from, to, value, data), "ERC1363: _checkAndCallTransfer reverts");
return true;
}
/**
* @dev Approve spender to transfer tokens and then execute a callback on recipient.
* @param spender The address allowed to transfer to
* @param value The amount allowed to be transferred
* @return A boolean that indicates if the operation was successful.
*/
function approveAndCall(address spender, uint256 value) public override returns (bool) {
return approveAndCallData(spender, value, "");
}
/**
* @dev Approve spender to transfer tokens and then execute a callback on recipient.
* @param spender The address allowed to transfer to.
* @param value The amount allowed to be transferred.
* @param data Additional data with no specified format.
* @return A boolean that indicates if the operation was successful.
*/
function approveAndCallData(address spender, uint256 value, bytes memory data) public override returns (bool) {
approve(spender, value);
require(_checkAndCallApprove(spender, value, data), "ERC1363: _checkAndCallApprove reverts");
return true;
}
/**
* @dev Internal function to invoke `onTransferReceived` on a target address
* The call is not executed if the target address is not a contract
* @param from address Representing the previous owner of the given token value
* @param to address Target address that will receive the tokens
* @param value uint256 The amount mount of tokens to be transferred
* @param data bytes Optional data to send along with the call
* @return whether the call correctly returned the expected magic value
*/
function _checkAndCallTransfer(address from, address to, uint256 value, bytes memory data) internal returns (bool) {
if (!to.isContract()) {
return false;
}
bytes4 retval = IERC1363Receiver(to).onTransferReceived(
_msgSender(), from, value, data
);
return (retval == _ERC1363_RECEIVED);
}
/**
* @dev Internal function to invoke `onApprovalReceived` on a target address
* The call is not executed if the target address is not a contract
* @param spender address The address which will spend the funds
* @param value uint256 The amount of tokens to be spent
* @param data bytes Optional data to send along with the call
* @return whether the call correctly returned the expected magic value
*/
function _checkAndCallApprove(address spender, uint256 value, bytes memory data) internal returns (bool) {
if (!spender.isContract()) {
return false;
}
bytes4 retval = IERC1363Spender(spender).onApprovalReceived(
_msgSender(), value, data
);
return (retval == _ERC1363_APPROVED);
}
} | /**
* @title ERC1363
* @author Vittorio Minacori (https://github.com/vittominacori)
* @dev Implementation of an ERC1363 interface
*/ | NatSpecMultiLine | transferAndCall | function transferAndCall(address to, uint256 value) public override returns (bool) {
return transferAndCallData(to, value, "");
}
| /**
* @dev Transfer tokens to a specified address and then execute a callback on recipient.
* @param to The address to transfer to.
* @param value The amount to be transferred.
* @return A boolean that indicates if the operation was successful.
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
2085,
2233
]
} | 9,119 |
Sav3rToken | erc-payable-token/contracts/token/ERC1363/IERC1363.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | ERC1363 | contract ERC1363 is ERC20, IERC1363, ERC165 {
using Address for address;
/*
* Note: the ERC-165 identifier for this interface is 0x4bbee2df.
* 0x4bbee2df ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)'))
*/
bytes4 internal constant _INTERFACE_ID_ERC1363_TRANSFER = 0x4bbee2df;
/*
* Note: the ERC-165 identifier for this interface is 0xfb9ec8ce.
* 0xfb9ec8ce ===
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
bytes4 internal constant _INTERFACE_ID_ERC1363_APPROVE = 0xfb9ec8ce;
// Equals to `bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))`
// which can be also obtained as `IERC1363Receiver(0).onTransferReceived.selector`
bytes4 private constant _ERC1363_RECEIVED = 0x88a7ca5c;
// Equals to `bytes4(keccak256("onApprovalReceived(address,uint256,bytes)"))`
// which can be also obtained as `IERC1363Spender(0).onApprovalReceived.selector`
bytes4 private constant _ERC1363_APPROVED = 0x7b04a2d0;
/**
* @param name Name of the token
* @param symbol A symbol to be used as ticker
*/
constructor (
string memory name,
string memory symbol
) public payable ERC20(name, symbol) {
// register the supported interfaces to conform to ERC1363 via ERC165
_registerInterface(_INTERFACE_ID_ERC1363_TRANSFER);
_registerInterface(_INTERFACE_ID_ERC1363_APPROVE);
}
/**
* @dev Transfer tokens to a specified address and then execute a callback on recipient.
* @param to The address to transfer to.
* @param value The amount to be transferred.
* @return A boolean that indicates if the operation was successful.
*/
function transferAndCall(address to, uint256 value) public override returns (bool) {
return transferAndCallData(to, value, "");
}
/**
* @dev Transfer tokens to a specified address and then execute a callback on recipient.
* @param to The address to transfer to
* @param value The amount to be transferred
* @param data Additional data with no specified format
* @return A boolean that indicates if the operation was successful.
*/
function transferAndCallData(address to, uint256 value, bytes memory data) public override returns (bool) {
transfer(to, value);
require(_checkAndCallTransfer(_msgSender(), to, value, data), "ERC1363: _checkAndCallTransfer reverts");
return true;
}
/**
* @dev Transfer tokens from one address to another and then execute a callback on recipient.
* @param from The address which you want to send tokens from
* @param to The address which you want to transfer to
* @param value The amount of tokens to be transferred
* @param data Additional data with no specified format
* @return A boolean that indicates if the operation was successful.
*/
function transferFromAndCallData(address from, address to, uint256 value, bytes memory data) public override returns (bool) {
transferFrom(from, to, value);
require(_checkAndCallTransfer(from, to, value, data), "ERC1363: _checkAndCallTransfer reverts");
return true;
}
/**
* @dev Approve spender to transfer tokens and then execute a callback on recipient.
* @param spender The address allowed to transfer to
* @param value The amount allowed to be transferred
* @return A boolean that indicates if the operation was successful.
*/
function approveAndCall(address spender, uint256 value) public override returns (bool) {
return approveAndCallData(spender, value, "");
}
/**
* @dev Approve spender to transfer tokens and then execute a callback on recipient.
* @param spender The address allowed to transfer to.
* @param value The amount allowed to be transferred.
* @param data Additional data with no specified format.
* @return A boolean that indicates if the operation was successful.
*/
function approveAndCallData(address spender, uint256 value, bytes memory data) public override returns (bool) {
approve(spender, value);
require(_checkAndCallApprove(spender, value, data), "ERC1363: _checkAndCallApprove reverts");
return true;
}
/**
* @dev Internal function to invoke `onTransferReceived` on a target address
* The call is not executed if the target address is not a contract
* @param from address Representing the previous owner of the given token value
* @param to address Target address that will receive the tokens
* @param value uint256 The amount mount of tokens to be transferred
* @param data bytes Optional data to send along with the call
* @return whether the call correctly returned the expected magic value
*/
function _checkAndCallTransfer(address from, address to, uint256 value, bytes memory data) internal returns (bool) {
if (!to.isContract()) {
return false;
}
bytes4 retval = IERC1363Receiver(to).onTransferReceived(
_msgSender(), from, value, data
);
return (retval == _ERC1363_RECEIVED);
}
/**
* @dev Internal function to invoke `onApprovalReceived` on a target address
* The call is not executed if the target address is not a contract
* @param spender address The address which will spend the funds
* @param value uint256 The amount of tokens to be spent
* @param data bytes Optional data to send along with the call
* @return whether the call correctly returned the expected magic value
*/
function _checkAndCallApprove(address spender, uint256 value, bytes memory data) internal returns (bool) {
if (!spender.isContract()) {
return false;
}
bytes4 retval = IERC1363Spender(spender).onApprovalReceived(
_msgSender(), value, data
);
return (retval == _ERC1363_APPROVED);
}
} | /**
* @title ERC1363
* @author Vittorio Minacori (https://github.com/vittominacori)
* @dev Implementation of an ERC1363 interface
*/ | NatSpecMultiLine | transferAndCallData | function transferAndCallData(address to, uint256 value, bytes memory data) public override returns (bool) {
transfer(to, value);
require(_checkAndCallTransfer(_msgSender(), to, value, data), "ERC1363: _checkAndCallTransfer reverts");
return true;
}
| /**
* @dev Transfer tokens to a specified address and then execute a callback on recipient.
* @param to The address to transfer to
* @param value The amount to be transferred
* @param data Additional data with no specified format
* @return A boolean that indicates if the operation was successful.
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
2578,
2863
]
} | 9,120 |
Sav3rToken | erc-payable-token/contracts/token/ERC1363/IERC1363.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | ERC1363 | contract ERC1363 is ERC20, IERC1363, ERC165 {
using Address for address;
/*
* Note: the ERC-165 identifier for this interface is 0x4bbee2df.
* 0x4bbee2df ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)'))
*/
bytes4 internal constant _INTERFACE_ID_ERC1363_TRANSFER = 0x4bbee2df;
/*
* Note: the ERC-165 identifier for this interface is 0xfb9ec8ce.
* 0xfb9ec8ce ===
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
bytes4 internal constant _INTERFACE_ID_ERC1363_APPROVE = 0xfb9ec8ce;
// Equals to `bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))`
// which can be also obtained as `IERC1363Receiver(0).onTransferReceived.selector`
bytes4 private constant _ERC1363_RECEIVED = 0x88a7ca5c;
// Equals to `bytes4(keccak256("onApprovalReceived(address,uint256,bytes)"))`
// which can be also obtained as `IERC1363Spender(0).onApprovalReceived.selector`
bytes4 private constant _ERC1363_APPROVED = 0x7b04a2d0;
/**
* @param name Name of the token
* @param symbol A symbol to be used as ticker
*/
constructor (
string memory name,
string memory symbol
) public payable ERC20(name, symbol) {
// register the supported interfaces to conform to ERC1363 via ERC165
_registerInterface(_INTERFACE_ID_ERC1363_TRANSFER);
_registerInterface(_INTERFACE_ID_ERC1363_APPROVE);
}
/**
* @dev Transfer tokens to a specified address and then execute a callback on recipient.
* @param to The address to transfer to.
* @param value The amount to be transferred.
* @return A boolean that indicates if the operation was successful.
*/
function transferAndCall(address to, uint256 value) public override returns (bool) {
return transferAndCallData(to, value, "");
}
/**
* @dev Transfer tokens to a specified address and then execute a callback on recipient.
* @param to The address to transfer to
* @param value The amount to be transferred
* @param data Additional data with no specified format
* @return A boolean that indicates if the operation was successful.
*/
function transferAndCallData(address to, uint256 value, bytes memory data) public override returns (bool) {
transfer(to, value);
require(_checkAndCallTransfer(_msgSender(), to, value, data), "ERC1363: _checkAndCallTransfer reverts");
return true;
}
/**
* @dev Transfer tokens from one address to another and then execute a callback on recipient.
* @param from The address which you want to send tokens from
* @param to The address which you want to transfer to
* @param value The amount of tokens to be transferred
* @param data Additional data with no specified format
* @return A boolean that indicates if the operation was successful.
*/
function transferFromAndCallData(address from, address to, uint256 value, bytes memory data) public override returns (bool) {
transferFrom(from, to, value);
require(_checkAndCallTransfer(from, to, value, data), "ERC1363: _checkAndCallTransfer reverts");
return true;
}
/**
* @dev Approve spender to transfer tokens and then execute a callback on recipient.
* @param spender The address allowed to transfer to
* @param value The amount allowed to be transferred
* @return A boolean that indicates if the operation was successful.
*/
function approveAndCall(address spender, uint256 value) public override returns (bool) {
return approveAndCallData(spender, value, "");
}
/**
* @dev Approve spender to transfer tokens and then execute a callback on recipient.
* @param spender The address allowed to transfer to.
* @param value The amount allowed to be transferred.
* @param data Additional data with no specified format.
* @return A boolean that indicates if the operation was successful.
*/
function approveAndCallData(address spender, uint256 value, bytes memory data) public override returns (bool) {
approve(spender, value);
require(_checkAndCallApprove(spender, value, data), "ERC1363: _checkAndCallApprove reverts");
return true;
}
/**
* @dev Internal function to invoke `onTransferReceived` on a target address
* The call is not executed if the target address is not a contract
* @param from address Representing the previous owner of the given token value
* @param to address Target address that will receive the tokens
* @param value uint256 The amount mount of tokens to be transferred
* @param data bytes Optional data to send along with the call
* @return whether the call correctly returned the expected magic value
*/
function _checkAndCallTransfer(address from, address to, uint256 value, bytes memory data) internal returns (bool) {
if (!to.isContract()) {
return false;
}
bytes4 retval = IERC1363Receiver(to).onTransferReceived(
_msgSender(), from, value, data
);
return (retval == _ERC1363_RECEIVED);
}
/**
* @dev Internal function to invoke `onApprovalReceived` on a target address
* The call is not executed if the target address is not a contract
* @param spender address The address which will spend the funds
* @param value uint256 The amount of tokens to be spent
* @param data bytes Optional data to send along with the call
* @return whether the call correctly returned the expected magic value
*/
function _checkAndCallApprove(address spender, uint256 value, bytes memory data) internal returns (bool) {
if (!spender.isContract()) {
return false;
}
bytes4 retval = IERC1363Spender(spender).onApprovalReceived(
_msgSender(), value, data
);
return (retval == _ERC1363_APPROVED);
}
} | /**
* @title ERC1363
* @author Vittorio Minacori (https://github.com/vittominacori)
* @dev Implementation of an ERC1363 interface
*/ | NatSpecMultiLine | transferFromAndCallData | function transferFromAndCallData(address from, address to, uint256 value, bytes memory data) public override returns (bool) {
transferFrom(from, to, value);
require(_checkAndCallTransfer(from, to, value, data), "ERC1363: _checkAndCallTransfer reverts");
return true;
}
| /**
* @dev Transfer tokens from one address to another and then execute a callback on recipient.
* @param from The address which you want to send tokens from
* @param to The address which you want to transfer to
* @param value The amount of tokens to be transferred
* @param data Additional data with no specified format
* @return A boolean that indicates if the operation was successful.
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
3309,
3614
]
} | 9,121 |
Sav3rToken | erc-payable-token/contracts/token/ERC1363/IERC1363.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | ERC1363 | contract ERC1363 is ERC20, IERC1363, ERC165 {
using Address for address;
/*
* Note: the ERC-165 identifier for this interface is 0x4bbee2df.
* 0x4bbee2df ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)'))
*/
bytes4 internal constant _INTERFACE_ID_ERC1363_TRANSFER = 0x4bbee2df;
/*
* Note: the ERC-165 identifier for this interface is 0xfb9ec8ce.
* 0xfb9ec8ce ===
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
bytes4 internal constant _INTERFACE_ID_ERC1363_APPROVE = 0xfb9ec8ce;
// Equals to `bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))`
// which can be also obtained as `IERC1363Receiver(0).onTransferReceived.selector`
bytes4 private constant _ERC1363_RECEIVED = 0x88a7ca5c;
// Equals to `bytes4(keccak256("onApprovalReceived(address,uint256,bytes)"))`
// which can be also obtained as `IERC1363Spender(0).onApprovalReceived.selector`
bytes4 private constant _ERC1363_APPROVED = 0x7b04a2d0;
/**
* @param name Name of the token
* @param symbol A symbol to be used as ticker
*/
constructor (
string memory name,
string memory symbol
) public payable ERC20(name, symbol) {
// register the supported interfaces to conform to ERC1363 via ERC165
_registerInterface(_INTERFACE_ID_ERC1363_TRANSFER);
_registerInterface(_INTERFACE_ID_ERC1363_APPROVE);
}
/**
* @dev Transfer tokens to a specified address and then execute a callback on recipient.
* @param to The address to transfer to.
* @param value The amount to be transferred.
* @return A boolean that indicates if the operation was successful.
*/
function transferAndCall(address to, uint256 value) public override returns (bool) {
return transferAndCallData(to, value, "");
}
/**
* @dev Transfer tokens to a specified address and then execute a callback on recipient.
* @param to The address to transfer to
* @param value The amount to be transferred
* @param data Additional data with no specified format
* @return A boolean that indicates if the operation was successful.
*/
function transferAndCallData(address to, uint256 value, bytes memory data) public override returns (bool) {
transfer(to, value);
require(_checkAndCallTransfer(_msgSender(), to, value, data), "ERC1363: _checkAndCallTransfer reverts");
return true;
}
/**
* @dev Transfer tokens from one address to another and then execute a callback on recipient.
* @param from The address which you want to send tokens from
* @param to The address which you want to transfer to
* @param value The amount of tokens to be transferred
* @param data Additional data with no specified format
* @return A boolean that indicates if the operation was successful.
*/
function transferFromAndCallData(address from, address to, uint256 value, bytes memory data) public override returns (bool) {
transferFrom(from, to, value);
require(_checkAndCallTransfer(from, to, value, data), "ERC1363: _checkAndCallTransfer reverts");
return true;
}
/**
* @dev Approve spender to transfer tokens and then execute a callback on recipient.
* @param spender The address allowed to transfer to
* @param value The amount allowed to be transferred
* @return A boolean that indicates if the operation was successful.
*/
function approveAndCall(address spender, uint256 value) public override returns (bool) {
return approveAndCallData(spender, value, "");
}
/**
* @dev Approve spender to transfer tokens and then execute a callback on recipient.
* @param spender The address allowed to transfer to.
* @param value The amount allowed to be transferred.
* @param data Additional data with no specified format.
* @return A boolean that indicates if the operation was successful.
*/
function approveAndCallData(address spender, uint256 value, bytes memory data) public override returns (bool) {
approve(spender, value);
require(_checkAndCallApprove(spender, value, data), "ERC1363: _checkAndCallApprove reverts");
return true;
}
/**
* @dev Internal function to invoke `onTransferReceived` on a target address
* The call is not executed if the target address is not a contract
* @param from address Representing the previous owner of the given token value
* @param to address Target address that will receive the tokens
* @param value uint256 The amount mount of tokens to be transferred
* @param data bytes Optional data to send along with the call
* @return whether the call correctly returned the expected magic value
*/
function _checkAndCallTransfer(address from, address to, uint256 value, bytes memory data) internal returns (bool) {
if (!to.isContract()) {
return false;
}
bytes4 retval = IERC1363Receiver(to).onTransferReceived(
_msgSender(), from, value, data
);
return (retval == _ERC1363_RECEIVED);
}
/**
* @dev Internal function to invoke `onApprovalReceived` on a target address
* The call is not executed if the target address is not a contract
* @param spender address The address which will spend the funds
* @param value uint256 The amount of tokens to be spent
* @param data bytes Optional data to send along with the call
* @return whether the call correctly returned the expected magic value
*/
function _checkAndCallApprove(address spender, uint256 value, bytes memory data) internal returns (bool) {
if (!spender.isContract()) {
return false;
}
bytes4 retval = IERC1363Spender(spender).onApprovalReceived(
_msgSender(), value, data
);
return (retval == _ERC1363_APPROVED);
}
} | /**
* @title ERC1363
* @author Vittorio Minacori (https://github.com/vittominacori)
* @dev Implementation of an ERC1363 interface
*/ | NatSpecMultiLine | approveAndCall | function approveAndCall(address spender, uint256 value) public override returns (bool) {
return approveAndCallData(spender, value, "");
}
| /**
* @dev Approve spender to transfer tokens and then execute a callback on recipient.
* @param spender The address allowed to transfer to
* @param value The amount allowed to be transferred
* @return A boolean that indicates if the operation was successful.
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
3915,
4071
]
} | 9,122 |
Sav3rToken | erc-payable-token/contracts/token/ERC1363/IERC1363.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | ERC1363 | contract ERC1363 is ERC20, IERC1363, ERC165 {
using Address for address;
/*
* Note: the ERC-165 identifier for this interface is 0x4bbee2df.
* 0x4bbee2df ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)'))
*/
bytes4 internal constant _INTERFACE_ID_ERC1363_TRANSFER = 0x4bbee2df;
/*
* Note: the ERC-165 identifier for this interface is 0xfb9ec8ce.
* 0xfb9ec8ce ===
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
bytes4 internal constant _INTERFACE_ID_ERC1363_APPROVE = 0xfb9ec8ce;
// Equals to `bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))`
// which can be also obtained as `IERC1363Receiver(0).onTransferReceived.selector`
bytes4 private constant _ERC1363_RECEIVED = 0x88a7ca5c;
// Equals to `bytes4(keccak256("onApprovalReceived(address,uint256,bytes)"))`
// which can be also obtained as `IERC1363Spender(0).onApprovalReceived.selector`
bytes4 private constant _ERC1363_APPROVED = 0x7b04a2d0;
/**
* @param name Name of the token
* @param symbol A symbol to be used as ticker
*/
constructor (
string memory name,
string memory symbol
) public payable ERC20(name, symbol) {
// register the supported interfaces to conform to ERC1363 via ERC165
_registerInterface(_INTERFACE_ID_ERC1363_TRANSFER);
_registerInterface(_INTERFACE_ID_ERC1363_APPROVE);
}
/**
* @dev Transfer tokens to a specified address and then execute a callback on recipient.
* @param to The address to transfer to.
* @param value The amount to be transferred.
* @return A boolean that indicates if the operation was successful.
*/
function transferAndCall(address to, uint256 value) public override returns (bool) {
return transferAndCallData(to, value, "");
}
/**
* @dev Transfer tokens to a specified address and then execute a callback on recipient.
* @param to The address to transfer to
* @param value The amount to be transferred
* @param data Additional data with no specified format
* @return A boolean that indicates if the operation was successful.
*/
function transferAndCallData(address to, uint256 value, bytes memory data) public override returns (bool) {
transfer(to, value);
require(_checkAndCallTransfer(_msgSender(), to, value, data), "ERC1363: _checkAndCallTransfer reverts");
return true;
}
/**
* @dev Transfer tokens from one address to another and then execute a callback on recipient.
* @param from The address which you want to send tokens from
* @param to The address which you want to transfer to
* @param value The amount of tokens to be transferred
* @param data Additional data with no specified format
* @return A boolean that indicates if the operation was successful.
*/
function transferFromAndCallData(address from, address to, uint256 value, bytes memory data) public override returns (bool) {
transferFrom(from, to, value);
require(_checkAndCallTransfer(from, to, value, data), "ERC1363: _checkAndCallTransfer reverts");
return true;
}
/**
* @dev Approve spender to transfer tokens and then execute a callback on recipient.
* @param spender The address allowed to transfer to
* @param value The amount allowed to be transferred
* @return A boolean that indicates if the operation was successful.
*/
function approveAndCall(address spender, uint256 value) public override returns (bool) {
return approveAndCallData(spender, value, "");
}
/**
* @dev Approve spender to transfer tokens and then execute a callback on recipient.
* @param spender The address allowed to transfer to.
* @param value The amount allowed to be transferred.
* @param data Additional data with no specified format.
* @return A boolean that indicates if the operation was successful.
*/
function approveAndCallData(address spender, uint256 value, bytes memory data) public override returns (bool) {
approve(spender, value);
require(_checkAndCallApprove(spender, value, data), "ERC1363: _checkAndCallApprove reverts");
return true;
}
/**
* @dev Internal function to invoke `onTransferReceived` on a target address
* The call is not executed if the target address is not a contract
* @param from address Representing the previous owner of the given token value
* @param to address Target address that will receive the tokens
* @param value uint256 The amount mount of tokens to be transferred
* @param data bytes Optional data to send along with the call
* @return whether the call correctly returned the expected magic value
*/
function _checkAndCallTransfer(address from, address to, uint256 value, bytes memory data) internal returns (bool) {
if (!to.isContract()) {
return false;
}
bytes4 retval = IERC1363Receiver(to).onTransferReceived(
_msgSender(), from, value, data
);
return (retval == _ERC1363_RECEIVED);
}
/**
* @dev Internal function to invoke `onApprovalReceived` on a target address
* The call is not executed if the target address is not a contract
* @param spender address The address which will spend the funds
* @param value uint256 The amount of tokens to be spent
* @param data bytes Optional data to send along with the call
* @return whether the call correctly returned the expected magic value
*/
function _checkAndCallApprove(address spender, uint256 value, bytes memory data) internal returns (bool) {
if (!spender.isContract()) {
return false;
}
bytes4 retval = IERC1363Spender(spender).onApprovalReceived(
_msgSender(), value, data
);
return (retval == _ERC1363_APPROVED);
}
} | /**
* @title ERC1363
* @author Vittorio Minacori (https://github.com/vittominacori)
* @dev Implementation of an ERC1363 interface
*/ | NatSpecMultiLine | approveAndCallData | function approveAndCallData(address spender, uint256 value, bytes memory data) public override returns (bool) {
approve(spender, value);
require(_checkAndCallApprove(spender, value, data), "ERC1363: _checkAndCallApprove reverts");
return true;
}
| /**
* @dev Approve spender to transfer tokens and then execute a callback on recipient.
* @param spender The address allowed to transfer to.
* @param value The amount allowed to be transferred.
* @param data Additional data with no specified format.
* @return A boolean that indicates if the operation was successful.
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
4436,
4718
]
} | 9,123 |
Sav3rToken | erc-payable-token/contracts/token/ERC1363/IERC1363.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | ERC1363 | contract ERC1363 is ERC20, IERC1363, ERC165 {
using Address for address;
/*
* Note: the ERC-165 identifier for this interface is 0x4bbee2df.
* 0x4bbee2df ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)'))
*/
bytes4 internal constant _INTERFACE_ID_ERC1363_TRANSFER = 0x4bbee2df;
/*
* Note: the ERC-165 identifier for this interface is 0xfb9ec8ce.
* 0xfb9ec8ce ===
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
bytes4 internal constant _INTERFACE_ID_ERC1363_APPROVE = 0xfb9ec8ce;
// Equals to `bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))`
// which can be also obtained as `IERC1363Receiver(0).onTransferReceived.selector`
bytes4 private constant _ERC1363_RECEIVED = 0x88a7ca5c;
// Equals to `bytes4(keccak256("onApprovalReceived(address,uint256,bytes)"))`
// which can be also obtained as `IERC1363Spender(0).onApprovalReceived.selector`
bytes4 private constant _ERC1363_APPROVED = 0x7b04a2d0;
/**
* @param name Name of the token
* @param symbol A symbol to be used as ticker
*/
constructor (
string memory name,
string memory symbol
) public payable ERC20(name, symbol) {
// register the supported interfaces to conform to ERC1363 via ERC165
_registerInterface(_INTERFACE_ID_ERC1363_TRANSFER);
_registerInterface(_INTERFACE_ID_ERC1363_APPROVE);
}
/**
* @dev Transfer tokens to a specified address and then execute a callback on recipient.
* @param to The address to transfer to.
* @param value The amount to be transferred.
* @return A boolean that indicates if the operation was successful.
*/
function transferAndCall(address to, uint256 value) public override returns (bool) {
return transferAndCallData(to, value, "");
}
/**
* @dev Transfer tokens to a specified address and then execute a callback on recipient.
* @param to The address to transfer to
* @param value The amount to be transferred
* @param data Additional data with no specified format
* @return A boolean that indicates if the operation was successful.
*/
function transferAndCallData(address to, uint256 value, bytes memory data) public override returns (bool) {
transfer(to, value);
require(_checkAndCallTransfer(_msgSender(), to, value, data), "ERC1363: _checkAndCallTransfer reverts");
return true;
}
/**
* @dev Transfer tokens from one address to another and then execute a callback on recipient.
* @param from The address which you want to send tokens from
* @param to The address which you want to transfer to
* @param value The amount of tokens to be transferred
* @param data Additional data with no specified format
* @return A boolean that indicates if the operation was successful.
*/
function transferFromAndCallData(address from, address to, uint256 value, bytes memory data) public override returns (bool) {
transferFrom(from, to, value);
require(_checkAndCallTransfer(from, to, value, data), "ERC1363: _checkAndCallTransfer reverts");
return true;
}
/**
* @dev Approve spender to transfer tokens and then execute a callback on recipient.
* @param spender The address allowed to transfer to
* @param value The amount allowed to be transferred
* @return A boolean that indicates if the operation was successful.
*/
function approveAndCall(address spender, uint256 value) public override returns (bool) {
return approveAndCallData(spender, value, "");
}
/**
* @dev Approve spender to transfer tokens and then execute a callback on recipient.
* @param spender The address allowed to transfer to.
* @param value The amount allowed to be transferred.
* @param data Additional data with no specified format.
* @return A boolean that indicates if the operation was successful.
*/
function approveAndCallData(address spender, uint256 value, bytes memory data) public override returns (bool) {
approve(spender, value);
require(_checkAndCallApprove(spender, value, data), "ERC1363: _checkAndCallApprove reverts");
return true;
}
/**
* @dev Internal function to invoke `onTransferReceived` on a target address
* The call is not executed if the target address is not a contract
* @param from address Representing the previous owner of the given token value
* @param to address Target address that will receive the tokens
* @param value uint256 The amount mount of tokens to be transferred
* @param data bytes Optional data to send along with the call
* @return whether the call correctly returned the expected magic value
*/
function _checkAndCallTransfer(address from, address to, uint256 value, bytes memory data) internal returns (bool) {
if (!to.isContract()) {
return false;
}
bytes4 retval = IERC1363Receiver(to).onTransferReceived(
_msgSender(), from, value, data
);
return (retval == _ERC1363_RECEIVED);
}
/**
* @dev Internal function to invoke `onApprovalReceived` on a target address
* The call is not executed if the target address is not a contract
* @param spender address The address which will spend the funds
* @param value uint256 The amount of tokens to be spent
* @param data bytes Optional data to send along with the call
* @return whether the call correctly returned the expected magic value
*/
function _checkAndCallApprove(address spender, uint256 value, bytes memory data) internal returns (bool) {
if (!spender.isContract()) {
return false;
}
bytes4 retval = IERC1363Spender(spender).onApprovalReceived(
_msgSender(), value, data
);
return (retval == _ERC1363_APPROVED);
}
} | /**
* @title ERC1363
* @author Vittorio Minacori (https://github.com/vittominacori)
* @dev Implementation of an ERC1363 interface
*/ | NatSpecMultiLine | _checkAndCallTransfer | function _checkAndCallTransfer(address from, address to, uint256 value, bytes memory data) internal returns (bool) {
if (!to.isContract()) {
return false;
}
bytes4 retval = IERC1363Receiver(to).onTransferReceived(
_msgSender(), from, value, data
);
return (retval == _ERC1363_RECEIVED);
}
| /**
* @dev Internal function to invoke `onTransferReceived` on a target address
* The call is not executed if the target address is not a contract
* @param from address Representing the previous owner of the given token value
* @param to address Target address that will receive the tokens
* @param value uint256 The amount mount of tokens to be transferred
* @param data bytes Optional data to send along with the call
* @return whether the call correctly returned the expected magic value
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
5269,
5638
]
} | 9,124 |
Sav3rToken | erc-payable-token/contracts/token/ERC1363/IERC1363.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | ERC1363 | contract ERC1363 is ERC20, IERC1363, ERC165 {
using Address for address;
/*
* Note: the ERC-165 identifier for this interface is 0x4bbee2df.
* 0x4bbee2df ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)'))
*/
bytes4 internal constant _INTERFACE_ID_ERC1363_TRANSFER = 0x4bbee2df;
/*
* Note: the ERC-165 identifier for this interface is 0xfb9ec8ce.
* 0xfb9ec8ce ===
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
bytes4 internal constant _INTERFACE_ID_ERC1363_APPROVE = 0xfb9ec8ce;
// Equals to `bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))`
// which can be also obtained as `IERC1363Receiver(0).onTransferReceived.selector`
bytes4 private constant _ERC1363_RECEIVED = 0x88a7ca5c;
// Equals to `bytes4(keccak256("onApprovalReceived(address,uint256,bytes)"))`
// which can be also obtained as `IERC1363Spender(0).onApprovalReceived.selector`
bytes4 private constant _ERC1363_APPROVED = 0x7b04a2d0;
/**
* @param name Name of the token
* @param symbol A symbol to be used as ticker
*/
constructor (
string memory name,
string memory symbol
) public payable ERC20(name, symbol) {
// register the supported interfaces to conform to ERC1363 via ERC165
_registerInterface(_INTERFACE_ID_ERC1363_TRANSFER);
_registerInterface(_INTERFACE_ID_ERC1363_APPROVE);
}
/**
* @dev Transfer tokens to a specified address and then execute a callback on recipient.
* @param to The address to transfer to.
* @param value The amount to be transferred.
* @return A boolean that indicates if the operation was successful.
*/
function transferAndCall(address to, uint256 value) public override returns (bool) {
return transferAndCallData(to, value, "");
}
/**
* @dev Transfer tokens to a specified address and then execute a callback on recipient.
* @param to The address to transfer to
* @param value The amount to be transferred
* @param data Additional data with no specified format
* @return A boolean that indicates if the operation was successful.
*/
function transferAndCallData(address to, uint256 value, bytes memory data) public override returns (bool) {
transfer(to, value);
require(_checkAndCallTransfer(_msgSender(), to, value, data), "ERC1363: _checkAndCallTransfer reverts");
return true;
}
/**
* @dev Transfer tokens from one address to another and then execute a callback on recipient.
* @param from The address which you want to send tokens from
* @param to The address which you want to transfer to
* @param value The amount of tokens to be transferred
* @param data Additional data with no specified format
* @return A boolean that indicates if the operation was successful.
*/
function transferFromAndCallData(address from, address to, uint256 value, bytes memory data) public override returns (bool) {
transferFrom(from, to, value);
require(_checkAndCallTransfer(from, to, value, data), "ERC1363: _checkAndCallTransfer reverts");
return true;
}
/**
* @dev Approve spender to transfer tokens and then execute a callback on recipient.
* @param spender The address allowed to transfer to
* @param value The amount allowed to be transferred
* @return A boolean that indicates if the operation was successful.
*/
function approveAndCall(address spender, uint256 value) public override returns (bool) {
return approveAndCallData(spender, value, "");
}
/**
* @dev Approve spender to transfer tokens and then execute a callback on recipient.
* @param spender The address allowed to transfer to.
* @param value The amount allowed to be transferred.
* @param data Additional data with no specified format.
* @return A boolean that indicates if the operation was successful.
*/
function approveAndCallData(address spender, uint256 value, bytes memory data) public override returns (bool) {
approve(spender, value);
require(_checkAndCallApprove(spender, value, data), "ERC1363: _checkAndCallApprove reverts");
return true;
}
/**
* @dev Internal function to invoke `onTransferReceived` on a target address
* The call is not executed if the target address is not a contract
* @param from address Representing the previous owner of the given token value
* @param to address Target address that will receive the tokens
* @param value uint256 The amount mount of tokens to be transferred
* @param data bytes Optional data to send along with the call
* @return whether the call correctly returned the expected magic value
*/
function _checkAndCallTransfer(address from, address to, uint256 value, bytes memory data) internal returns (bool) {
if (!to.isContract()) {
return false;
}
bytes4 retval = IERC1363Receiver(to).onTransferReceived(
_msgSender(), from, value, data
);
return (retval == _ERC1363_RECEIVED);
}
/**
* @dev Internal function to invoke `onApprovalReceived` on a target address
* The call is not executed if the target address is not a contract
* @param spender address The address which will spend the funds
* @param value uint256 The amount of tokens to be spent
* @param data bytes Optional data to send along with the call
* @return whether the call correctly returned the expected magic value
*/
function _checkAndCallApprove(address spender, uint256 value, bytes memory data) internal returns (bool) {
if (!spender.isContract()) {
return false;
}
bytes4 retval = IERC1363Spender(spender).onApprovalReceived(
_msgSender(), value, data
);
return (retval == _ERC1363_APPROVED);
}
} | /**
* @title ERC1363
* @author Vittorio Minacori (https://github.com/vittominacori)
* @dev Implementation of an ERC1363 interface
*/ | NatSpecMultiLine | _checkAndCallApprove | function _checkAndCallApprove(address spender, uint256 value, bytes memory data) internal returns (bool) {
if (!spender.isContract()) {
return false;
}
bytes4 retval = IERC1363Spender(spender).onApprovalReceived(
_msgSender(), value, data
);
return (retval == _ERC1363_APPROVED);
}
| /**
* @dev Internal function to invoke `onApprovalReceived` on a target address
* The call is not executed if the target address is not a contract
* @param spender address The address which will spend the funds
* @param value uint256 The amount of tokens to be spent
* @param data bytes Optional data to send along with the call
* @return whether the call correctly returned the expected magic value
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
6092,
6454
]
} | 9,125 |
Sav3rToken | erc-payable-token/contracts/token/ERC1363/IERC1363.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | Ownable | contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() internal view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. 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.
*/
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
} | /**
* @dev 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.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/ | NatSpecMultiLine | owner | function owner() internal view returns (address) {
return _owner;
}
| /**
* @dev Returns the address of the current owner.
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
497,
583
]
} | 9,126 |
Sav3rToken | erc-payable-token/contracts/token/ERC1363/IERC1363.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | TokenRecover | contract TokenRecover is Ownable {
/**
* @dev Remember that only owner can call so be careful when use on contracts generated from other contracts.
* @param tokenAddress The token contract address
* @param tokenAmount Number of tokens to be sent
*/
function recoverERC20(address tokenAddress, uint256 tokenAmount) internal onlyOwner {
IERC20(tokenAddress).transfer(owner(), tokenAmount);
}
} | /**
* @title TokenRecover
* @author Vittorio Minacori (https://github.com/vittominacori)
* @dev Allow to recover any ERC20 sent into the contract for error
*/ | NatSpecMultiLine | recoverERC20 | function recoverERC20(address tokenAddress, uint256 tokenAmount) internal onlyOwner {
IERC20(tokenAddress).transfer(owner(), tokenAmount);
}
| /**
* @dev Remember that only owner can call so be careful when use on contracts generated from other contracts.
* @param tokenAddress The token contract address
* @param tokenAmount Number of tokens to be sent
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
281,
440
]
} | 9,127 |
MetaScyra | @openzeppelin/contracts/access/Ownable.sol | 0xd7c57fc28f72cc8ffbd635155d924f0ac3f03f8e | Solidity | Ownable | abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_setOwner(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. 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.
*/
function renounceOwnership() public virtual onlyOwner {
_setOwner(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_setOwner(newOwner);
}
function _setOwner(address newOwner) private {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
} | /**
* @dev 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.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/ | NatSpecMultiLine | owner | function owner() public view virtual returns (address) {
return _owner;
}
| /**
* @dev Returns the address of the current owner.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://672fc76424cd92c353e6de815b9bcc53701f37d5371e3774b462983f8ad2f3fe | {
"func_code_index": [
399,
491
]
} | 9,128 |
MetaScyra | @openzeppelin/contracts/access/Ownable.sol | 0xd7c57fc28f72cc8ffbd635155d924f0ac3f03f8e | Solidity | Ownable | abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_setOwner(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. 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.
*/
function renounceOwnership() public virtual onlyOwner {
_setOwner(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_setOwner(newOwner);
}
function _setOwner(address newOwner) private {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
} | /**
* @dev 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.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/ | NatSpecMultiLine | renounceOwnership | function renounceOwnership() public virtual onlyOwner {
_setOwner(address(0));
}
| /**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. 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.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://672fc76424cd92c353e6de815b9bcc53701f37d5371e3774b462983f8ad2f3fe | {
"func_code_index": [
1050,
1149
]
} | 9,129 |
MetaScyra | @openzeppelin/contracts/access/Ownable.sol | 0xd7c57fc28f72cc8ffbd635155d924f0ac3f03f8e | Solidity | Ownable | abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_setOwner(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. 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.
*/
function renounceOwnership() public virtual onlyOwner {
_setOwner(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_setOwner(newOwner);
}
function _setOwner(address newOwner) private {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
} | /**
* @dev 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.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/ | NatSpecMultiLine | transferOwnership | function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_setOwner(newOwner);
}
| /**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://672fc76424cd92c353e6de815b9bcc53701f37d5371e3774b462983f8ad2f3fe | {
"func_code_index": [
1299,
1496
]
} | 9,130 |
MetaScyra | @openzeppelin/contracts/access/Ownable.sol | 0xd7c57fc28f72cc8ffbd635155d924f0ac3f03f8e | Solidity | ECDSA | library ECDSA {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS,
InvalidSignatureV
}
function _throwError(RecoverError error) private pure {
if (error == RecoverError.NoError) {
return; // no error: do nothing
} else if (error == RecoverError.InvalidSignature) {
revert("ECDSA: invalid signature");
} else if (error == RecoverError.InvalidSignatureLength) {
revert("ECDSA: invalid signature length");
} else if (error == RecoverError.InvalidSignatureS) {
revert("ECDSA: invalid signature 's' value");
} else if (error == RecoverError.InvalidSignatureV) {
revert("ECDSA: invalid signature 'v' value");
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature` or error string. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*
* Documentation for signature generation:
* - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
* - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
// Check the signature length
// - case 65: r,s,v signature (standard)
// - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else if (signature.length == 64) {
bytes32 r;
bytes32 vs;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
assembly {
r := mload(add(signature, 0x20))
vs := mload(add(signature, 0x40))
}
return tryRecover(hash, r, vs);
} else {
return (address(0), RecoverError.InvalidSignatureLength);
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, signature);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
*
* See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address, RecoverError) {
bytes32 s;
uint8 v;
assembly {
s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
v := add(shr(255, vs), 27)
}
return tryRecover(hash, v, r, s);
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address, RecoverError) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS);
}
if (v != 27 && v != 28) {
return (address(0), RecoverError.InvalidSignatureV);
}
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature);
}
return (signer, RecoverError.NoError);
}
} | tryRecover | function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
// Check the signature length
// - case 65: r,s,v signature (standard)
// - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else if (signature.length == 64) {
bytes32 r;
bytes32 vs;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
assembly {
r := mload(add(signature, 0x20))
vs := mload(add(signature, 0x40))
}
return tryRecover(hash, r, vs);
} else {
return (address(0), RecoverError.InvalidSignatureLength);
}
}
| /**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature` or error string. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*
* Documentation for signature generation:
* - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
* - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
*
* _Available since v4.3._
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://672fc76424cd92c353e6de815b9bcc53701f37d5371e3774b462983f8ad2f3fe | {
"func_code_index": [
1913,
3226
]
} | 9,131 |
||
MetaScyra | @openzeppelin/contracts/access/Ownable.sol | 0xd7c57fc28f72cc8ffbd635155d924f0ac3f03f8e | Solidity | ECDSA | library ECDSA {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS,
InvalidSignatureV
}
function _throwError(RecoverError error) private pure {
if (error == RecoverError.NoError) {
return; // no error: do nothing
} else if (error == RecoverError.InvalidSignature) {
revert("ECDSA: invalid signature");
} else if (error == RecoverError.InvalidSignatureLength) {
revert("ECDSA: invalid signature length");
} else if (error == RecoverError.InvalidSignatureS) {
revert("ECDSA: invalid signature 's' value");
} else if (error == RecoverError.InvalidSignatureV) {
revert("ECDSA: invalid signature 'v' value");
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature` or error string. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*
* Documentation for signature generation:
* - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
* - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
// Check the signature length
// - case 65: r,s,v signature (standard)
// - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else if (signature.length == 64) {
bytes32 r;
bytes32 vs;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
assembly {
r := mload(add(signature, 0x20))
vs := mload(add(signature, 0x40))
}
return tryRecover(hash, r, vs);
} else {
return (address(0), RecoverError.InvalidSignatureLength);
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, signature);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
*
* See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address, RecoverError) {
bytes32 s;
uint8 v;
assembly {
s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
v := add(shr(255, vs), 27)
}
return tryRecover(hash, v, r, s);
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address, RecoverError) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS);
}
if (v != 27 && v != 28) {
return (address(0), RecoverError.InvalidSignatureV);
}
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature);
}
return (signer, RecoverError.NoError);
}
} | recover | function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, signature);
_throwError(error);
return recovered;
}
| /**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://672fc76424cd92c353e6de815b9bcc53701f37d5371e3774b462983f8ad2f3fe | {
"func_code_index": [
4023,
4259
]
} | 9,132 |
||
MetaScyra | @openzeppelin/contracts/access/Ownable.sol | 0xd7c57fc28f72cc8ffbd635155d924f0ac3f03f8e | Solidity | ECDSA | library ECDSA {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS,
InvalidSignatureV
}
function _throwError(RecoverError error) private pure {
if (error == RecoverError.NoError) {
return; // no error: do nothing
} else if (error == RecoverError.InvalidSignature) {
revert("ECDSA: invalid signature");
} else if (error == RecoverError.InvalidSignatureLength) {
revert("ECDSA: invalid signature length");
} else if (error == RecoverError.InvalidSignatureS) {
revert("ECDSA: invalid signature 's' value");
} else if (error == RecoverError.InvalidSignatureV) {
revert("ECDSA: invalid signature 'v' value");
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature` or error string. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*
* Documentation for signature generation:
* - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
* - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
// Check the signature length
// - case 65: r,s,v signature (standard)
// - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else if (signature.length == 64) {
bytes32 r;
bytes32 vs;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
assembly {
r := mload(add(signature, 0x20))
vs := mload(add(signature, 0x40))
}
return tryRecover(hash, r, vs);
} else {
return (address(0), RecoverError.InvalidSignatureLength);
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, signature);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
*
* See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address, RecoverError) {
bytes32 s;
uint8 v;
assembly {
s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
v := add(shr(255, vs), 27)
}
return tryRecover(hash, v, r, s);
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address, RecoverError) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS);
}
if (v != 27 && v != 28) {
return (address(0), RecoverError.InvalidSignatureV);
}
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature);
}
return (signer, RecoverError.NoError);
}
} | tryRecover | function tryRecover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address, RecoverError) {
bytes32 s;
uint8 v;
assembly {
s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
v := add(shr(255, vs), 27)
}
return tryRecover(hash, v, r, s);
}
| /**
* @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
*
* See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
*
* _Available since v4.3._
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://672fc76424cd92c353e6de815b9bcc53701f37d5371e3774b462983f8ad2f3fe | {
"func_code_index": [
4517,
4913
]
} | 9,133 |
||
MetaScyra | @openzeppelin/contracts/access/Ownable.sol | 0xd7c57fc28f72cc8ffbd635155d924f0ac3f03f8e | Solidity | ECDSA | library ECDSA {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS,
InvalidSignatureV
}
function _throwError(RecoverError error) private pure {
if (error == RecoverError.NoError) {
return; // no error: do nothing
} else if (error == RecoverError.InvalidSignature) {
revert("ECDSA: invalid signature");
} else if (error == RecoverError.InvalidSignatureLength) {
revert("ECDSA: invalid signature length");
} else if (error == RecoverError.InvalidSignatureS) {
revert("ECDSA: invalid signature 's' value");
} else if (error == RecoverError.InvalidSignatureV) {
revert("ECDSA: invalid signature 'v' value");
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature` or error string. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*
* Documentation for signature generation:
* - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
* - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
// Check the signature length
// - case 65: r,s,v signature (standard)
// - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else if (signature.length == 64) {
bytes32 r;
bytes32 vs;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
assembly {
r := mload(add(signature, 0x20))
vs := mload(add(signature, 0x40))
}
return tryRecover(hash, r, vs);
} else {
return (address(0), RecoverError.InvalidSignatureLength);
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, signature);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
*
* See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address, RecoverError) {
bytes32 s;
uint8 v;
assembly {
s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
v := add(shr(255, vs), 27)
}
return tryRecover(hash, v, r, s);
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address, RecoverError) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS);
}
if (v != 27 && v != 28) {
return (address(0), RecoverError.InvalidSignatureV);
}
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature);
}
return (signer, RecoverError.NoError);
}
} | tryRecover | function tryRecover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address, RecoverError) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS);
}
if (v != 27 && v != 28) {
return (address(0), RecoverError.InvalidSignatureV);
}
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature);
}
return (signer, RecoverError.NoError);
}
| /**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*
* _Available since v4.3._
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://672fc76424cd92c353e6de815b9bcc53701f37d5371e3774b462983f8ad2f3fe | {
"func_code_index": [
5090,
6724
]
} | 9,134 |
||
MetaScyra | @openzeppelin/contracts/access/Ownable.sol | 0xd7c57fc28f72cc8ffbd635155d924f0ac3f03f8e | Solidity | MetaScyra | contract MetaScyra is Ownable, ERC721EnumerableB {
using ECDSA for bytes32;
using Strings for uint256;
struct Stake {
uint256 tokenId;
uint256 timestamp;
}
uint256 public constant SCYRA_MAX = 6667;
uint256 public constant SCYRA_GENESIS_MAX = 667;
uint256 public constant SCYRA_GIFT = 53;
uint256 public constant SCYRA_PER_MINT = 2;
uint256 public constant SCYRA_PURCHASE_LIMIT = 2;
uint256 public constant SCYRA_PRESALE_PURCHASE_LIMIT = 2;
uint256 public constant SCYRA_GENESIS_PRICE = 0.15 ether;
uint256 public constant SCYRA_PRICE = 0.088 ether;
uint256 public giftedAmount;
string public provenance;
string private _tokenBaseURI;
address private scyra1 = 0x5243891d7641C0b87695437494ae23A17aB582eB;
address private scyra2 = 0x9DB6dDabe3d8b6181d36367a00D56666cf5c0e97;
address private scyra3 = 0xb8fc44EB23fc325356198818D0Ef2fec7aC0b6D7;
address private scyra4 = 0xE35ff894bDf9B92d02f118717385aB1337A4b6df;
address private scyra5 = 0xea1c9C2152b77835B06f4aD5dF84f6964A1d2117;
address private scyra6 = 0x39B4fb38391D3Df364894C3fc9166832Bf52ba81;
address private scyra7 = 0xb550adB2e2d39D02e9f3A4B85237AB303666230d;
address private scyra8 = 0x4A5056FC80494023E53b2238aE0DE60Cd106E9d9;
address private scyra9 = 0xb032Cc4bD2295b51b07ea0AA43C3465c8F3ABe2b;
address private scyra10 = 0x8a907097c89d76766EdEC06Bd3B38917B94Ef9dE;
address private scyra11 = 0xB8A9021C9c054a0e7A1e7cC9ac8fD21bc8974Bd3;
address private scyra12 = 0x5F69C83e97B4e410b2f5eAC172854900c72b7927;
address private signerAddress = 0x6f65E7A2bd16fA95D5f99d3Bc82594304670a118;
bool public presaleLive;
bool public saleLive;
bool public genesisPresaleLive;
bool public genesisLive;
mapping(address => uint256) private presalerListPurchases;
mapping(address => uint256) private purchases;
mapping(address => uint256) private genesisPresalePurchases;
mapping(address => uint256) private genesisPurchases;
mapping(uint256 => Stake) public stakes;
mapping(uint256 => address) private isStaking;
mapping(uint256 => uint256) public stakingTime;
constructor(
string memory baseUri
) ERC721B("MetaScyra", "SCYRA") {
_tokenBaseURI = baseUri;
// zero id
_mint( msg.sender, 0 );
// auction
_mint( msg.sender, 1 );
_mint( msg.sender, 2 );
_mint( msg.sender, 3 );
_mint( msg.sender, 4 );
_mint( msg.sender, 5 );
_mint( msg.sender, 6 );
// team genesis
_mint( scyra1, 7 );
_mint( scyra1, 8 );
_mint( scyra2, 9 );
_mint( scyra3, 10 );
_mint( scyra4, 11 );
_mint( scyra5, 12 );
_mint( scyra6, 13 );
_mint( scyra7, 14 );
_mint( scyra8, 15 );
_mint( scyra9, 16 );
_mint( scyra12, 17 );
}
/* ---- Functions ---- */
function stake(uint256 _tokenId) public {
_transfer(msg.sender, address(this), _tokenId);
stakingTime[_tokenId] = 0;
stakes[_tokenId] = Stake(_tokenId, block.timestamp);
_setStaking(msg.sender, _tokenId);
}
function unstake(uint256 _tokenId) public {
require(isStaking[_tokenId] == msg.sender, "NO_PERMISSION");
stakingTime[_tokenId] += (block.timestamp - stakes[_tokenId].timestamp);
_unStake(_tokenId);
_transfer(address(this), msg.sender, _tokenId);
delete stakes[_tokenId];
}
function buy(bytes32 hash, bytes memory signature, uint256 tokenQuantity) external payable {
require(saleLive, "SALE_CLOSED");
require(!presaleLive, "ONLY_PRESALE");
require(tokenQuantity <= SCYRA_PER_MINT, "EXCEED_SCYRA_PER_MINT");
require(SCYRA_PRICE * tokenQuantity <= msg.value, "INSUFFICIENT_ETH");
require(totalSupply() + tokenQuantity <= SCYRA_MAX, "EXCEED_MAX_SALE_SUPPLY");
require(purchases[msg.sender] + tokenQuantity <= SCYRA_PURCHASE_LIMIT, "EXCEED_ALLOC");
require(matchAddressSigner(hash, signature), "NO_DIRECT_MINT");
purchases[msg.sender] += tokenQuantity;
for(uint256 i = 0; i < tokenQuantity; i++) {
uint mintIndex = totalSupply();
_mint( msg.sender, mintIndex );
}
}
function presaleBuy(bytes32 hash, bytes memory signature, uint256 tokenQuantity) external payable {
require(!saleLive && presaleLive, "PRESALE_CLOSED");
require(tokenQuantity <= SCYRA_PER_MINT, "EXCEED_SCYRA_PER_MINT");
require(SCYRA_PRICE * tokenQuantity <= msg.value, "INSUFFICIENT_ETH");
require(totalSupply() + tokenQuantity <= SCYRA_MAX, "EXCEED_MAX_SALE_SUPPLY");
require(presalerListPurchases[msg.sender] + tokenQuantity <= SCYRA_PRESALE_PURCHASE_LIMIT, "EXCEED_ALLOC");
require(matchAddressSigner(hash, signature), "NO_DIRECT_MINT");
presalerListPurchases[msg.sender] += tokenQuantity;
for (uint256 i = 0; i < tokenQuantity; i++) {
uint mintIndex = totalSupply();
_mint( msg.sender, mintIndex );
}
}
function buyGenesis(bytes32 hash, bytes memory signature, uint256 tokenQuantity) external payable {
require(genesisLive, "SALE_CLOSED");
require(!genesisPresaleLive, "ONLY_PRESALE");
require(tokenQuantity <= SCYRA_PER_MINT, "EXCEED_SCYRA_PER_MINT");
require(SCYRA_GENESIS_PRICE * tokenQuantity <= msg.value, "INSUFFICIENT_ETH");
require(totalSupply() + tokenQuantity <= SCYRA_GENESIS_MAX, "EXCEED_MAX_SALE_SUPPLY");
require(genesisPurchases[msg.sender] + tokenQuantity <= SCYRA_PURCHASE_LIMIT, "EXCEED_ALLOC");
require(matchAddressSigner(hash, signature), "NO_DIRECT_MINT");
genesisPurchases[msg.sender] += tokenQuantity;
for(uint256 i = 0; i < tokenQuantity; i++) {
uint mintIndex = totalSupply();
_mint( msg.sender, mintIndex );
}
}
function presaleBuyGenesis(bytes32 hash, bytes memory signature, uint256 tokenQuantity) external payable {
require(!genesisLive && genesisPresaleLive, "PRESALE_CLOSED");
require(tokenQuantity <= SCYRA_PER_MINT, "EXCEED_SCYRA_PER_MINT");
require(SCYRA_GENESIS_PRICE * tokenQuantity <= msg.value, "INSUFFICIENT_ETH");
require(totalSupply() + tokenQuantity <= SCYRA_GENESIS_MAX, "EXCEED_MAX_SALE_SUPPLY");
require(genesisPresalePurchases[msg.sender] + tokenQuantity <= SCYRA_PRESALE_PURCHASE_LIMIT, "EXCEED_ALLOC");
require(matchAddressSigner(hash, signature), "NO_DIRECT_MINT");
genesisPresalePurchases[msg.sender] += tokenQuantity;
for (uint256 i = 0; i < tokenQuantity; i++) {
uint mintIndex = totalSupply();
_mint( msg.sender, mintIndex );
}
}
function withdraw() external onlyOwner {
uint balance = address(this).balance;
_withdraw(scyra1, balance * 29 / 100);
_withdraw(scyra2, balance * 15 / 100);
_withdraw(scyra3, balance * 20 / 100);
_withdraw(scyra4, balance * 5 / 100);
_withdraw(scyra5, balance * 5 / 100);
_withdraw(scyra6, balance * 1 / 100);
_withdraw(scyra7, balance * 12 / 1000);
_withdraw(scyra8, balance * 5 / 100);
_withdraw(scyra9, balance * 8 / 1000);
_withdraw(scyra10, balance * 3 / 100);
_withdraw(scyra11, balance * 12 / 100);
_withdraw(scyra12, balance * 3 / 100);
}
function _withdraw(address _address, uint256 _amount) private {
(bool success, ) = _address.call{value: _amount}("");
require(success, "Transfer failed.");
}
function gift(address _to, uint256 _reserveAmount) external onlyOwner {
require(totalSupply() + _reserveAmount <= SCYRA_MAX, "MAX_MINT");
require(giftedAmount + _reserveAmount <= SCYRA_GIFT, "NO_GIFTS");
giftedAmount += _reserveAmount;
for (uint256 i = 0; i < _reserveAmount; i++) {
uint mintIndex = totalSupply();
_safeMint( _to, mintIndex );
}
}
/* ---- Setters ---- */
function togglePresaleStatus() external onlyOwner {
presaleLive = !presaleLive;
}
function toggleSaleStatus() external onlyOwner {
saleLive = !saleLive;
}
function toggleGenesisPresaleStatus() external onlyOwner {
genesisPresaleLive = !genesisPresaleLive;
}
function toggleGenesisSaleStatus() external onlyOwner {
genesisLive = !genesisLive;
}
function setBaseURI(string calldata URI) external onlyOwner {
_tokenBaseURI = URI;
}
function setProvenanceHash(string calldata hash) external onlyOwner {
provenance = hash;
}
function setSignerAddress(address _signerAddress) external onlyOwner {
signerAddress = _signerAddress;
}
/* ---- Misc ---- */
function _setStaking(address _owner, uint256 _tokenId) internal {
isStaking[_tokenId] = _owner;
}
function _unStake(uint256 _tokenId) internal {
require(isStaking[_tokenId] == msg.sender, "NOT_AUTHORIZED");
isStaking[_tokenId] = address(0);
}
function matchAddressSigner(bytes32 hash, bytes memory signature) private view returns(bool) {
return signerAddress == hash.recover(signature);
}
function tokenURI(uint256 tokenId) external view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
return string(abi.encodePacked(_tokenBaseURI, tokenId.toString()));
}
function tokensOfOwner(address addr) external view returns(uint256[] memory) {
uint256 tokenCount = balanceOf(addr);
uint256[] memory tokensId = new uint256[](tokenCount);
for(uint256 i; i < tokenCount; i++){
tokensId[i] = tokenOfOwnerByIndex(addr, i);
}
return tokensId;
}
} | stake | function stake(uint256 _tokenId) public {
_transfer(msg.sender, address(this), _tokenId);
stakingTime[_tokenId] = 0;
stakes[_tokenId] = Stake(_tokenId, block.timestamp);
_setStaking(msg.sender, _tokenId);
}
| /* ---- Functions ---- */ | Comment | v0.8.9+commit.e5eed63a | MIT | ipfs://672fc76424cd92c353e6de815b9bcc53701f37d5371e3774b462983f8ad2f3fe | {
"func_code_index": [
3043,
3295
]
} | 9,135 |
||
MetaScyra | @openzeppelin/contracts/access/Ownable.sol | 0xd7c57fc28f72cc8ffbd635155d924f0ac3f03f8e | Solidity | MetaScyra | contract MetaScyra is Ownable, ERC721EnumerableB {
using ECDSA for bytes32;
using Strings for uint256;
struct Stake {
uint256 tokenId;
uint256 timestamp;
}
uint256 public constant SCYRA_MAX = 6667;
uint256 public constant SCYRA_GENESIS_MAX = 667;
uint256 public constant SCYRA_GIFT = 53;
uint256 public constant SCYRA_PER_MINT = 2;
uint256 public constant SCYRA_PURCHASE_LIMIT = 2;
uint256 public constant SCYRA_PRESALE_PURCHASE_LIMIT = 2;
uint256 public constant SCYRA_GENESIS_PRICE = 0.15 ether;
uint256 public constant SCYRA_PRICE = 0.088 ether;
uint256 public giftedAmount;
string public provenance;
string private _tokenBaseURI;
address private scyra1 = 0x5243891d7641C0b87695437494ae23A17aB582eB;
address private scyra2 = 0x9DB6dDabe3d8b6181d36367a00D56666cf5c0e97;
address private scyra3 = 0xb8fc44EB23fc325356198818D0Ef2fec7aC0b6D7;
address private scyra4 = 0xE35ff894bDf9B92d02f118717385aB1337A4b6df;
address private scyra5 = 0xea1c9C2152b77835B06f4aD5dF84f6964A1d2117;
address private scyra6 = 0x39B4fb38391D3Df364894C3fc9166832Bf52ba81;
address private scyra7 = 0xb550adB2e2d39D02e9f3A4B85237AB303666230d;
address private scyra8 = 0x4A5056FC80494023E53b2238aE0DE60Cd106E9d9;
address private scyra9 = 0xb032Cc4bD2295b51b07ea0AA43C3465c8F3ABe2b;
address private scyra10 = 0x8a907097c89d76766EdEC06Bd3B38917B94Ef9dE;
address private scyra11 = 0xB8A9021C9c054a0e7A1e7cC9ac8fD21bc8974Bd3;
address private scyra12 = 0x5F69C83e97B4e410b2f5eAC172854900c72b7927;
address private signerAddress = 0x6f65E7A2bd16fA95D5f99d3Bc82594304670a118;
bool public presaleLive;
bool public saleLive;
bool public genesisPresaleLive;
bool public genesisLive;
mapping(address => uint256) private presalerListPurchases;
mapping(address => uint256) private purchases;
mapping(address => uint256) private genesisPresalePurchases;
mapping(address => uint256) private genesisPurchases;
mapping(uint256 => Stake) public stakes;
mapping(uint256 => address) private isStaking;
mapping(uint256 => uint256) public stakingTime;
constructor(
string memory baseUri
) ERC721B("MetaScyra", "SCYRA") {
_tokenBaseURI = baseUri;
// zero id
_mint( msg.sender, 0 );
// auction
_mint( msg.sender, 1 );
_mint( msg.sender, 2 );
_mint( msg.sender, 3 );
_mint( msg.sender, 4 );
_mint( msg.sender, 5 );
_mint( msg.sender, 6 );
// team genesis
_mint( scyra1, 7 );
_mint( scyra1, 8 );
_mint( scyra2, 9 );
_mint( scyra3, 10 );
_mint( scyra4, 11 );
_mint( scyra5, 12 );
_mint( scyra6, 13 );
_mint( scyra7, 14 );
_mint( scyra8, 15 );
_mint( scyra9, 16 );
_mint( scyra12, 17 );
}
/* ---- Functions ---- */
function stake(uint256 _tokenId) public {
_transfer(msg.sender, address(this), _tokenId);
stakingTime[_tokenId] = 0;
stakes[_tokenId] = Stake(_tokenId, block.timestamp);
_setStaking(msg.sender, _tokenId);
}
function unstake(uint256 _tokenId) public {
require(isStaking[_tokenId] == msg.sender, "NO_PERMISSION");
stakingTime[_tokenId] += (block.timestamp - stakes[_tokenId].timestamp);
_unStake(_tokenId);
_transfer(address(this), msg.sender, _tokenId);
delete stakes[_tokenId];
}
function buy(bytes32 hash, bytes memory signature, uint256 tokenQuantity) external payable {
require(saleLive, "SALE_CLOSED");
require(!presaleLive, "ONLY_PRESALE");
require(tokenQuantity <= SCYRA_PER_MINT, "EXCEED_SCYRA_PER_MINT");
require(SCYRA_PRICE * tokenQuantity <= msg.value, "INSUFFICIENT_ETH");
require(totalSupply() + tokenQuantity <= SCYRA_MAX, "EXCEED_MAX_SALE_SUPPLY");
require(purchases[msg.sender] + tokenQuantity <= SCYRA_PURCHASE_LIMIT, "EXCEED_ALLOC");
require(matchAddressSigner(hash, signature), "NO_DIRECT_MINT");
purchases[msg.sender] += tokenQuantity;
for(uint256 i = 0; i < tokenQuantity; i++) {
uint mintIndex = totalSupply();
_mint( msg.sender, mintIndex );
}
}
function presaleBuy(bytes32 hash, bytes memory signature, uint256 tokenQuantity) external payable {
require(!saleLive && presaleLive, "PRESALE_CLOSED");
require(tokenQuantity <= SCYRA_PER_MINT, "EXCEED_SCYRA_PER_MINT");
require(SCYRA_PRICE * tokenQuantity <= msg.value, "INSUFFICIENT_ETH");
require(totalSupply() + tokenQuantity <= SCYRA_MAX, "EXCEED_MAX_SALE_SUPPLY");
require(presalerListPurchases[msg.sender] + tokenQuantity <= SCYRA_PRESALE_PURCHASE_LIMIT, "EXCEED_ALLOC");
require(matchAddressSigner(hash, signature), "NO_DIRECT_MINT");
presalerListPurchases[msg.sender] += tokenQuantity;
for (uint256 i = 0; i < tokenQuantity; i++) {
uint mintIndex = totalSupply();
_mint( msg.sender, mintIndex );
}
}
function buyGenesis(bytes32 hash, bytes memory signature, uint256 tokenQuantity) external payable {
require(genesisLive, "SALE_CLOSED");
require(!genesisPresaleLive, "ONLY_PRESALE");
require(tokenQuantity <= SCYRA_PER_MINT, "EXCEED_SCYRA_PER_MINT");
require(SCYRA_GENESIS_PRICE * tokenQuantity <= msg.value, "INSUFFICIENT_ETH");
require(totalSupply() + tokenQuantity <= SCYRA_GENESIS_MAX, "EXCEED_MAX_SALE_SUPPLY");
require(genesisPurchases[msg.sender] + tokenQuantity <= SCYRA_PURCHASE_LIMIT, "EXCEED_ALLOC");
require(matchAddressSigner(hash, signature), "NO_DIRECT_MINT");
genesisPurchases[msg.sender] += tokenQuantity;
for(uint256 i = 0; i < tokenQuantity; i++) {
uint mintIndex = totalSupply();
_mint( msg.sender, mintIndex );
}
}
function presaleBuyGenesis(bytes32 hash, bytes memory signature, uint256 tokenQuantity) external payable {
require(!genesisLive && genesisPresaleLive, "PRESALE_CLOSED");
require(tokenQuantity <= SCYRA_PER_MINT, "EXCEED_SCYRA_PER_MINT");
require(SCYRA_GENESIS_PRICE * tokenQuantity <= msg.value, "INSUFFICIENT_ETH");
require(totalSupply() + tokenQuantity <= SCYRA_GENESIS_MAX, "EXCEED_MAX_SALE_SUPPLY");
require(genesisPresalePurchases[msg.sender] + tokenQuantity <= SCYRA_PRESALE_PURCHASE_LIMIT, "EXCEED_ALLOC");
require(matchAddressSigner(hash, signature), "NO_DIRECT_MINT");
genesisPresalePurchases[msg.sender] += tokenQuantity;
for (uint256 i = 0; i < tokenQuantity; i++) {
uint mintIndex = totalSupply();
_mint( msg.sender, mintIndex );
}
}
function withdraw() external onlyOwner {
uint balance = address(this).balance;
_withdraw(scyra1, balance * 29 / 100);
_withdraw(scyra2, balance * 15 / 100);
_withdraw(scyra3, balance * 20 / 100);
_withdraw(scyra4, balance * 5 / 100);
_withdraw(scyra5, balance * 5 / 100);
_withdraw(scyra6, balance * 1 / 100);
_withdraw(scyra7, balance * 12 / 1000);
_withdraw(scyra8, balance * 5 / 100);
_withdraw(scyra9, balance * 8 / 1000);
_withdraw(scyra10, balance * 3 / 100);
_withdraw(scyra11, balance * 12 / 100);
_withdraw(scyra12, balance * 3 / 100);
}
function _withdraw(address _address, uint256 _amount) private {
(bool success, ) = _address.call{value: _amount}("");
require(success, "Transfer failed.");
}
function gift(address _to, uint256 _reserveAmount) external onlyOwner {
require(totalSupply() + _reserveAmount <= SCYRA_MAX, "MAX_MINT");
require(giftedAmount + _reserveAmount <= SCYRA_GIFT, "NO_GIFTS");
giftedAmount += _reserveAmount;
for (uint256 i = 0; i < _reserveAmount; i++) {
uint mintIndex = totalSupply();
_safeMint( _to, mintIndex );
}
}
/* ---- Setters ---- */
function togglePresaleStatus() external onlyOwner {
presaleLive = !presaleLive;
}
function toggleSaleStatus() external onlyOwner {
saleLive = !saleLive;
}
function toggleGenesisPresaleStatus() external onlyOwner {
genesisPresaleLive = !genesisPresaleLive;
}
function toggleGenesisSaleStatus() external onlyOwner {
genesisLive = !genesisLive;
}
function setBaseURI(string calldata URI) external onlyOwner {
_tokenBaseURI = URI;
}
function setProvenanceHash(string calldata hash) external onlyOwner {
provenance = hash;
}
function setSignerAddress(address _signerAddress) external onlyOwner {
signerAddress = _signerAddress;
}
/* ---- Misc ---- */
function _setStaking(address _owner, uint256 _tokenId) internal {
isStaking[_tokenId] = _owner;
}
function _unStake(uint256 _tokenId) internal {
require(isStaking[_tokenId] == msg.sender, "NOT_AUTHORIZED");
isStaking[_tokenId] = address(0);
}
function matchAddressSigner(bytes32 hash, bytes memory signature) private view returns(bool) {
return signerAddress == hash.recover(signature);
}
function tokenURI(uint256 tokenId) external view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
return string(abi.encodePacked(_tokenBaseURI, tokenId.toString()));
}
function tokensOfOwner(address addr) external view returns(uint256[] memory) {
uint256 tokenCount = balanceOf(addr);
uint256[] memory tokensId = new uint256[](tokenCount);
for(uint256 i; i < tokenCount; i++){
tokensId[i] = tokenOfOwnerByIndex(addr, i);
}
return tokensId;
}
} | togglePresaleStatus | function togglePresaleStatus() external onlyOwner {
presaleLive = !presaleLive;
}
| /* ---- Setters ---- */ | Comment | v0.8.9+commit.e5eed63a | MIT | ipfs://672fc76424cd92c353e6de815b9bcc53701f37d5371e3774b462983f8ad2f3fe | {
"func_code_index": [
8358,
8459
]
} | 9,136 |
||
MetaScyra | @openzeppelin/contracts/access/Ownable.sol | 0xd7c57fc28f72cc8ffbd635155d924f0ac3f03f8e | Solidity | MetaScyra | contract MetaScyra is Ownable, ERC721EnumerableB {
using ECDSA for bytes32;
using Strings for uint256;
struct Stake {
uint256 tokenId;
uint256 timestamp;
}
uint256 public constant SCYRA_MAX = 6667;
uint256 public constant SCYRA_GENESIS_MAX = 667;
uint256 public constant SCYRA_GIFT = 53;
uint256 public constant SCYRA_PER_MINT = 2;
uint256 public constant SCYRA_PURCHASE_LIMIT = 2;
uint256 public constant SCYRA_PRESALE_PURCHASE_LIMIT = 2;
uint256 public constant SCYRA_GENESIS_PRICE = 0.15 ether;
uint256 public constant SCYRA_PRICE = 0.088 ether;
uint256 public giftedAmount;
string public provenance;
string private _tokenBaseURI;
address private scyra1 = 0x5243891d7641C0b87695437494ae23A17aB582eB;
address private scyra2 = 0x9DB6dDabe3d8b6181d36367a00D56666cf5c0e97;
address private scyra3 = 0xb8fc44EB23fc325356198818D0Ef2fec7aC0b6D7;
address private scyra4 = 0xE35ff894bDf9B92d02f118717385aB1337A4b6df;
address private scyra5 = 0xea1c9C2152b77835B06f4aD5dF84f6964A1d2117;
address private scyra6 = 0x39B4fb38391D3Df364894C3fc9166832Bf52ba81;
address private scyra7 = 0xb550adB2e2d39D02e9f3A4B85237AB303666230d;
address private scyra8 = 0x4A5056FC80494023E53b2238aE0DE60Cd106E9d9;
address private scyra9 = 0xb032Cc4bD2295b51b07ea0AA43C3465c8F3ABe2b;
address private scyra10 = 0x8a907097c89d76766EdEC06Bd3B38917B94Ef9dE;
address private scyra11 = 0xB8A9021C9c054a0e7A1e7cC9ac8fD21bc8974Bd3;
address private scyra12 = 0x5F69C83e97B4e410b2f5eAC172854900c72b7927;
address private signerAddress = 0x6f65E7A2bd16fA95D5f99d3Bc82594304670a118;
bool public presaleLive;
bool public saleLive;
bool public genesisPresaleLive;
bool public genesisLive;
mapping(address => uint256) private presalerListPurchases;
mapping(address => uint256) private purchases;
mapping(address => uint256) private genesisPresalePurchases;
mapping(address => uint256) private genesisPurchases;
mapping(uint256 => Stake) public stakes;
mapping(uint256 => address) private isStaking;
mapping(uint256 => uint256) public stakingTime;
constructor(
string memory baseUri
) ERC721B("MetaScyra", "SCYRA") {
_tokenBaseURI = baseUri;
// zero id
_mint( msg.sender, 0 );
// auction
_mint( msg.sender, 1 );
_mint( msg.sender, 2 );
_mint( msg.sender, 3 );
_mint( msg.sender, 4 );
_mint( msg.sender, 5 );
_mint( msg.sender, 6 );
// team genesis
_mint( scyra1, 7 );
_mint( scyra1, 8 );
_mint( scyra2, 9 );
_mint( scyra3, 10 );
_mint( scyra4, 11 );
_mint( scyra5, 12 );
_mint( scyra6, 13 );
_mint( scyra7, 14 );
_mint( scyra8, 15 );
_mint( scyra9, 16 );
_mint( scyra12, 17 );
}
/* ---- Functions ---- */
function stake(uint256 _tokenId) public {
_transfer(msg.sender, address(this), _tokenId);
stakingTime[_tokenId] = 0;
stakes[_tokenId] = Stake(_tokenId, block.timestamp);
_setStaking(msg.sender, _tokenId);
}
function unstake(uint256 _tokenId) public {
require(isStaking[_tokenId] == msg.sender, "NO_PERMISSION");
stakingTime[_tokenId] += (block.timestamp - stakes[_tokenId].timestamp);
_unStake(_tokenId);
_transfer(address(this), msg.sender, _tokenId);
delete stakes[_tokenId];
}
function buy(bytes32 hash, bytes memory signature, uint256 tokenQuantity) external payable {
require(saleLive, "SALE_CLOSED");
require(!presaleLive, "ONLY_PRESALE");
require(tokenQuantity <= SCYRA_PER_MINT, "EXCEED_SCYRA_PER_MINT");
require(SCYRA_PRICE * tokenQuantity <= msg.value, "INSUFFICIENT_ETH");
require(totalSupply() + tokenQuantity <= SCYRA_MAX, "EXCEED_MAX_SALE_SUPPLY");
require(purchases[msg.sender] + tokenQuantity <= SCYRA_PURCHASE_LIMIT, "EXCEED_ALLOC");
require(matchAddressSigner(hash, signature), "NO_DIRECT_MINT");
purchases[msg.sender] += tokenQuantity;
for(uint256 i = 0; i < tokenQuantity; i++) {
uint mintIndex = totalSupply();
_mint( msg.sender, mintIndex );
}
}
function presaleBuy(bytes32 hash, bytes memory signature, uint256 tokenQuantity) external payable {
require(!saleLive && presaleLive, "PRESALE_CLOSED");
require(tokenQuantity <= SCYRA_PER_MINT, "EXCEED_SCYRA_PER_MINT");
require(SCYRA_PRICE * tokenQuantity <= msg.value, "INSUFFICIENT_ETH");
require(totalSupply() + tokenQuantity <= SCYRA_MAX, "EXCEED_MAX_SALE_SUPPLY");
require(presalerListPurchases[msg.sender] + tokenQuantity <= SCYRA_PRESALE_PURCHASE_LIMIT, "EXCEED_ALLOC");
require(matchAddressSigner(hash, signature), "NO_DIRECT_MINT");
presalerListPurchases[msg.sender] += tokenQuantity;
for (uint256 i = 0; i < tokenQuantity; i++) {
uint mintIndex = totalSupply();
_mint( msg.sender, mintIndex );
}
}
function buyGenesis(bytes32 hash, bytes memory signature, uint256 tokenQuantity) external payable {
require(genesisLive, "SALE_CLOSED");
require(!genesisPresaleLive, "ONLY_PRESALE");
require(tokenQuantity <= SCYRA_PER_MINT, "EXCEED_SCYRA_PER_MINT");
require(SCYRA_GENESIS_PRICE * tokenQuantity <= msg.value, "INSUFFICIENT_ETH");
require(totalSupply() + tokenQuantity <= SCYRA_GENESIS_MAX, "EXCEED_MAX_SALE_SUPPLY");
require(genesisPurchases[msg.sender] + tokenQuantity <= SCYRA_PURCHASE_LIMIT, "EXCEED_ALLOC");
require(matchAddressSigner(hash, signature), "NO_DIRECT_MINT");
genesisPurchases[msg.sender] += tokenQuantity;
for(uint256 i = 0; i < tokenQuantity; i++) {
uint mintIndex = totalSupply();
_mint( msg.sender, mintIndex );
}
}
function presaleBuyGenesis(bytes32 hash, bytes memory signature, uint256 tokenQuantity) external payable {
require(!genesisLive && genesisPresaleLive, "PRESALE_CLOSED");
require(tokenQuantity <= SCYRA_PER_MINT, "EXCEED_SCYRA_PER_MINT");
require(SCYRA_GENESIS_PRICE * tokenQuantity <= msg.value, "INSUFFICIENT_ETH");
require(totalSupply() + tokenQuantity <= SCYRA_GENESIS_MAX, "EXCEED_MAX_SALE_SUPPLY");
require(genesisPresalePurchases[msg.sender] + tokenQuantity <= SCYRA_PRESALE_PURCHASE_LIMIT, "EXCEED_ALLOC");
require(matchAddressSigner(hash, signature), "NO_DIRECT_MINT");
genesisPresalePurchases[msg.sender] += tokenQuantity;
for (uint256 i = 0; i < tokenQuantity; i++) {
uint mintIndex = totalSupply();
_mint( msg.sender, mintIndex );
}
}
function withdraw() external onlyOwner {
uint balance = address(this).balance;
_withdraw(scyra1, balance * 29 / 100);
_withdraw(scyra2, balance * 15 / 100);
_withdraw(scyra3, balance * 20 / 100);
_withdraw(scyra4, balance * 5 / 100);
_withdraw(scyra5, balance * 5 / 100);
_withdraw(scyra6, balance * 1 / 100);
_withdraw(scyra7, balance * 12 / 1000);
_withdraw(scyra8, balance * 5 / 100);
_withdraw(scyra9, balance * 8 / 1000);
_withdraw(scyra10, balance * 3 / 100);
_withdraw(scyra11, balance * 12 / 100);
_withdraw(scyra12, balance * 3 / 100);
}
function _withdraw(address _address, uint256 _amount) private {
(bool success, ) = _address.call{value: _amount}("");
require(success, "Transfer failed.");
}
function gift(address _to, uint256 _reserveAmount) external onlyOwner {
require(totalSupply() + _reserveAmount <= SCYRA_MAX, "MAX_MINT");
require(giftedAmount + _reserveAmount <= SCYRA_GIFT, "NO_GIFTS");
giftedAmount += _reserveAmount;
for (uint256 i = 0; i < _reserveAmount; i++) {
uint mintIndex = totalSupply();
_safeMint( _to, mintIndex );
}
}
/* ---- Setters ---- */
function togglePresaleStatus() external onlyOwner {
presaleLive = !presaleLive;
}
function toggleSaleStatus() external onlyOwner {
saleLive = !saleLive;
}
function toggleGenesisPresaleStatus() external onlyOwner {
genesisPresaleLive = !genesisPresaleLive;
}
function toggleGenesisSaleStatus() external onlyOwner {
genesisLive = !genesisLive;
}
function setBaseURI(string calldata URI) external onlyOwner {
_tokenBaseURI = URI;
}
function setProvenanceHash(string calldata hash) external onlyOwner {
provenance = hash;
}
function setSignerAddress(address _signerAddress) external onlyOwner {
signerAddress = _signerAddress;
}
/* ---- Misc ---- */
function _setStaking(address _owner, uint256 _tokenId) internal {
isStaking[_tokenId] = _owner;
}
function _unStake(uint256 _tokenId) internal {
require(isStaking[_tokenId] == msg.sender, "NOT_AUTHORIZED");
isStaking[_tokenId] = address(0);
}
function matchAddressSigner(bytes32 hash, bytes memory signature) private view returns(bool) {
return signerAddress == hash.recover(signature);
}
function tokenURI(uint256 tokenId) external view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
return string(abi.encodePacked(_tokenBaseURI, tokenId.toString()));
}
function tokensOfOwner(address addr) external view returns(uint256[] memory) {
uint256 tokenCount = balanceOf(addr);
uint256[] memory tokensId = new uint256[](tokenCount);
for(uint256 i; i < tokenCount; i++){
tokensId[i] = tokenOfOwnerByIndex(addr, i);
}
return tokensId;
}
} | _setStaking | function _setStaking(address _owner, uint256 _tokenId) internal {
isStaking[_tokenId] = _owner;
}
| /* ---- Misc ---- */ | Comment | v0.8.9+commit.e5eed63a | MIT | ipfs://672fc76424cd92c353e6de815b9bcc53701f37d5371e3774b462983f8ad2f3fe | {
"func_code_index": [
9166,
9282
]
} | 9,137 |
||
Pettametti | contracts/Pettametti.sol | 0x52474fbf6b678a280d0c69f2314d6d95548b3daf | Solidity | Pettametti | contract Pettametti is ERC721Enumerable, Ownable, RandomlyAssigned {
using Strings for uint256;
string public baseExtension = ".json";
uint256 public cost = 0.00 ether;
uint256 public maxMettiSupply = 300;
uint256 public maxPettaSupply = 300;
uint256 public maxMintAmount = 20;
bool public paused = false;
string public baseURI = "https://ipfs.io/ipfs/QmRgXjdjTTFtzJEiXrD3atGJxQZ8nXFbtLuP8C2TX3Ykkc/";
//Allow OG Pumpametti holders to mint for free
address public MettiAddress = 0x09646c5c1e42ede848A57d6542382C32f2877164;
MettiInterface MettiContract = MettiInterface(MettiAddress);
uint public MettiOwnersSupplyMinted = 0;
uint public publicSupplyMinted = 0;
constructor(
) ERC721("Pettametti", "Petta")
RandomlyAssigned(300, 1) {}
// internal
function _baseURI() internal view virtual override returns (string memory) {
return baseURI;
}
function MettiFreeMint(uint mettiId) public payable {
require(mettiId > 0 && mettiId <= 300, "Token ID invalid");
require(MettiContract.ownerOf(mettiId) == msg.sender, "Not the owner of this pumpametti");
_safeMint(msg.sender, mettiId);
}
function MettiMultiFreeMint(uint256[] memory mettiIds) public payable {
for (uint256 i = 0; i < mettiIds.length; i++) {
require(MettiContract.ownerOf(mettiIds[i]) == msg.sender, "Not the owner of this pumpametti");
_safeMint(_msgSender(), mettiIds[i]);
}
}
function walletOfOwner(address _owner)
public
view
returns (uint256[] memory)
{
uint256 ownerTokenCount = balanceOf(_owner);
uint256[] memory tokenIds = new uint256[](ownerTokenCount);
for (uint256 i; i < ownerTokenCount; i++) {
tokenIds[i] = tokenOfOwnerByIndex(_owner, i);
}
return tokenIds;
}
function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory)
{
require(
_exists(tokenId),
"ERC721Metadata: URI query for nonexistent token"
);
string memory currentBaseURI = _baseURI();
return bytes(currentBaseURI).length > 0
? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension))
: "";
}
//only owner
function withdraw() public payable onlyOwner {
require(payable(msg.sender).send(address(this).balance));
}
} | _baseURI | function _baseURI() internal view virtual override returns (string memory) {
return baseURI;
}
| // internal | LineComment | v0.8.9+commit.e5eed63a | MIT | ipfs://d1459db360142237f84a253eb41c3e2b66cbbf0f729f116ab5c992a969585d77 | {
"func_code_index": [
822,
927
]
} | 9,138 |
||
Pettametti | contracts/Pettametti.sol | 0x52474fbf6b678a280d0c69f2314d6d95548b3daf | Solidity | Pettametti | contract Pettametti is ERC721Enumerable, Ownable, RandomlyAssigned {
using Strings for uint256;
string public baseExtension = ".json";
uint256 public cost = 0.00 ether;
uint256 public maxMettiSupply = 300;
uint256 public maxPettaSupply = 300;
uint256 public maxMintAmount = 20;
bool public paused = false;
string public baseURI = "https://ipfs.io/ipfs/QmRgXjdjTTFtzJEiXrD3atGJxQZ8nXFbtLuP8C2TX3Ykkc/";
//Allow OG Pumpametti holders to mint for free
address public MettiAddress = 0x09646c5c1e42ede848A57d6542382C32f2877164;
MettiInterface MettiContract = MettiInterface(MettiAddress);
uint public MettiOwnersSupplyMinted = 0;
uint public publicSupplyMinted = 0;
constructor(
) ERC721("Pettametti", "Petta")
RandomlyAssigned(300, 1) {}
// internal
function _baseURI() internal view virtual override returns (string memory) {
return baseURI;
}
function MettiFreeMint(uint mettiId) public payable {
require(mettiId > 0 && mettiId <= 300, "Token ID invalid");
require(MettiContract.ownerOf(mettiId) == msg.sender, "Not the owner of this pumpametti");
_safeMint(msg.sender, mettiId);
}
function MettiMultiFreeMint(uint256[] memory mettiIds) public payable {
for (uint256 i = 0; i < mettiIds.length; i++) {
require(MettiContract.ownerOf(mettiIds[i]) == msg.sender, "Not the owner of this pumpametti");
_safeMint(_msgSender(), mettiIds[i]);
}
}
function walletOfOwner(address _owner)
public
view
returns (uint256[] memory)
{
uint256 ownerTokenCount = balanceOf(_owner);
uint256[] memory tokenIds = new uint256[](ownerTokenCount);
for (uint256 i; i < ownerTokenCount; i++) {
tokenIds[i] = tokenOfOwnerByIndex(_owner, i);
}
return tokenIds;
}
function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory)
{
require(
_exists(tokenId),
"ERC721Metadata: URI query for nonexistent token"
);
string memory currentBaseURI = _baseURI();
return bytes(currentBaseURI).length > 0
? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension))
: "";
}
//only owner
function withdraw() public payable onlyOwner {
require(payable(msg.sender).send(address(this).balance));
}
} | withdraw | function withdraw() public payable onlyOwner {
require(payable(msg.sender).send(address(this).balance));
}
| //only owner | LineComment | v0.8.9+commit.e5eed63a | MIT | ipfs://d1459db360142237f84a253eb41c3e2b66cbbf0f729f116ab5c992a969585d77 | {
"func_code_index": [
2322,
2439
]
} | 9,139 |
||
BitMonsters | contracts/Integer.sol | 0xbd091f143ee754f1d755494441aee781d918cb93 | Solidity | Integer | library Integer {
/**
* @dev Gets the bit at the given position in the given integer.
* 31 is the leftmost bit, 0 is the rightmost bit.
*
* For example: bitAt(2, 0) == 0, because the rightmost bit of 10 is 0
* bitAt(2, 1) == 1, because the second to last bit of 10 is 1
*/
function bitAt(uint integer, uint pos) external pure returns (uint) {
require(pos <= 31, "pos > 31");
return (integer & (1 << pos)) >> pos;
}
/**
* @dev Gets the value of the bits between left and right, both inclusive, in the given integer.
* 31 is the leftmost bit, 0 is the rightmost bit.
*
* For example: bitsFrom(10, 3, 1) == 7 (101 in binary), because 10 is *101*0 in binary
* bitsFrom(10, 2, 0) == 2 (010 in binary), because 10 is 1*010* in binary
*/
function bitsFrom(uint integer, uint left, uint right) external pure returns (uint) {
require(left >= right, "left > right");
require(left <= 31, "left > 31");
uint delta = left - right + 1;
return (integer & (((1 << delta) - 1) << right)) >> right;
}
} | bitAt | function bitAt(uint integer, uint pos) external pure returns (uint) {
require(pos <= 31, "pos > 31");
return (integer & (1 << pos)) >> pos;
}
| /**
* @dev Gets the bit at the given position in the given integer.
* 31 is the leftmost bit, 0 is the rightmost bit.
*
* For example: bitAt(2, 0) == 0, because the rightmost bit of 10 is 0
* bitAt(2, 1) == 1, because the second to last bit of 10 is 1
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | MIT | ipfs://2641bc0a6897496103acbb493c7a9a096bcedd65afb1cb130ed46a31f4554f73 | {
"func_code_index": [
343,
514
]
} | 9,140 |
||
BitMonsters | contracts/Integer.sol | 0xbd091f143ee754f1d755494441aee781d918cb93 | Solidity | Integer | library Integer {
/**
* @dev Gets the bit at the given position in the given integer.
* 31 is the leftmost bit, 0 is the rightmost bit.
*
* For example: bitAt(2, 0) == 0, because the rightmost bit of 10 is 0
* bitAt(2, 1) == 1, because the second to last bit of 10 is 1
*/
function bitAt(uint integer, uint pos) external pure returns (uint) {
require(pos <= 31, "pos > 31");
return (integer & (1 << pos)) >> pos;
}
/**
* @dev Gets the value of the bits between left and right, both inclusive, in the given integer.
* 31 is the leftmost bit, 0 is the rightmost bit.
*
* For example: bitsFrom(10, 3, 1) == 7 (101 in binary), because 10 is *101*0 in binary
* bitsFrom(10, 2, 0) == 2 (010 in binary), because 10 is 1*010* in binary
*/
function bitsFrom(uint integer, uint left, uint right) external pure returns (uint) {
require(left >= right, "left > right");
require(left <= 31, "left > 31");
uint delta = left - right + 1;
return (integer & (((1 << delta) - 1) << right)) >> right;
}
} | bitsFrom | function bitsFrom(uint integer, uint left, uint right) external pure returns (uint) {
require(left >= right, "left > right");
require(left <= 31, "left > 31");
uint delta = left - right + 1;
return (integer & (((1 << delta) - 1) << right)) >> right;
}
| /**
* @dev Gets the value of the bits between left and right, both inclusive, in the given integer.
* 31 is the leftmost bit, 0 is the rightmost bit.
*
* For example: bitsFrom(10, 3, 1) == 7 (101 in binary), because 10 is *101*0 in binary
* bitsFrom(10, 2, 0) == 2 (010 in binary), because 10 is 1*010* in binary
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | MIT | ipfs://2641bc0a6897496103acbb493c7a9a096bcedd65afb1cb130ed46a31f4554f73 | {
"func_code_index": [
908,
1209
]
} | 9,141 |
||
BitMonsters | contracts/StringBuffer.sol | 0xbd091f143ee754f1d755494441aee781d918cb93 | Solidity | StringBufferLibrary | library StringBufferLibrary {
/**
* @dev Copies 32 bytes of `src` starting at `srcIndex` into `dst` starting at `dstIndex`.
*/
function memcpy32(string memory src, uint srcIndex, bytes memory dst, uint dstIndex) internal pure {
assembly {
mstore(add(add(dst, 32), dstIndex), mload(add(add(src, 32), srcIndex)))
}
}
/**
* @dev Copies 1 bytes of `src` at `srcIndex` into `dst` at `dstIndex`.
* This uses the same amount of gas as `memcpy32`, so prefer `memcpy32` if at all possible.
*/
function memcpy1(string memory src, uint srcIndex, bytes memory dst, uint dstIndex) internal pure {
assembly {
mstore8(add(add(dst, 32), dstIndex), shr(248, mload(add(add(src, 32), srcIndex))))
}
}
/**
* @dev Copies a string into `dst` starting at `dstIndex` with a maximum length of `dstLen`.
* This function will not write beyond `dstLen`. However, if `dstLen` is not reached, it may write zeros beyond the length of the string.
*/
function copyString(string memory src, bytes memory dst, uint dstIndex, uint dstLen) internal pure returns (uint) {
uint srcIndex;
uint srcLen = bytes(src).length;
for (; srcLen > 31 && srcIndex < srcLen && srcIndex < dstLen - 31; srcIndex += 32) {
memcpy32(src, srcIndex, dst, dstIndex + srcIndex);
}
for (; srcIndex < srcLen && srcIndex < dstLen; ++srcIndex) {
memcpy1(src, srcIndex, dst, dstIndex + srcIndex);
}
return dstIndex + srcLen;
}
/**
* @dev Adds `str` to the end of the internal buffer.
*/
function pushToStringBuffer(StringBuffer memory self, string memory str) internal pure returns (StringBuffer memory) {
if (self.buffer.length == self.numberOfStrings) {
string[] memory newBuffer = new string[](self.buffer.length * 2);
for (uint i = 0; i < self.buffer.length; ++i) {
newBuffer[i] = self.buffer[i];
}
self.buffer = newBuffer;
}
self.buffer[self.numberOfStrings] = str;
self.numberOfStrings++;
self.totalStringLength += bytes(str).length;
return self;
}
/**
* @dev Concatenates `str` to the end of the last string in the internal buffer.
*/
function concatToLastString(StringBuffer memory self, string memory str) internal pure {
if (self.numberOfStrings == 0) {
self.numberOfStrings++;
}
uint idx = self.numberOfStrings - 1;
self.buffer[idx] = string(abi.encodePacked(self.buffer[idx], str));
self.totalStringLength += bytes(str).length;
}
/**
* @notice Creates a new empty StringBuffer
* @dev The initial capacity is 16 strings
*/
function empty() external pure returns (StringBuffer memory) {
return StringBuffer(new string[](1), 0, 0);
}
/**
* @notice Converts the contents of the StringBuffer into a string.
* @dev This runs in O(n) time.
*/
function get(StringBuffer memory self) internal pure returns (string memory) {
bytes memory output = new bytes(self.totalStringLength);
uint ptr = 0;
for (uint i = 0; i < self.numberOfStrings; ++i) {
ptr = copyString(self.buffer[i], output, ptr, self.totalStringLength);
}
return string(output);
}
/**
* @notice Appends a string to the end of the StringBuffer
* @dev Internally the StringBuffer keeps a `string[]` that doubles in size when extra capacity is needed.
*/
function append(StringBuffer memory self, string memory str) internal pure {
uint idx = self.numberOfStrings == 0 ? 0 : self.numberOfStrings - 1;
if (bytes(self.buffer[idx]).length + bytes(str).length <= 1024) {
concatToLastString(self, str);
} else {
pushToStringBuffer(self, str);
}
}
} | memcpy32 | function memcpy32(string memory src, uint srcIndex, bytes memory dst, uint dstIndex) internal pure {
assembly {
mstore(add(add(dst, 32), dstIndex), mload(add(add(src, 32), srcIndex)))
}
}
| /**
* @dev Copies 32 bytes of `src` starting at `srcIndex` into `dst` starting at `dstIndex`.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | MIT | ipfs://2641bc0a6897496103acbb493c7a9a096bcedd65afb1cb130ed46a31f4554f73 | {
"func_code_index": [
145,
373
]
} | 9,142 |
||
BitMonsters | contracts/StringBuffer.sol | 0xbd091f143ee754f1d755494441aee781d918cb93 | Solidity | StringBufferLibrary | library StringBufferLibrary {
/**
* @dev Copies 32 bytes of `src` starting at `srcIndex` into `dst` starting at `dstIndex`.
*/
function memcpy32(string memory src, uint srcIndex, bytes memory dst, uint dstIndex) internal pure {
assembly {
mstore(add(add(dst, 32), dstIndex), mload(add(add(src, 32), srcIndex)))
}
}
/**
* @dev Copies 1 bytes of `src` at `srcIndex` into `dst` at `dstIndex`.
* This uses the same amount of gas as `memcpy32`, so prefer `memcpy32` if at all possible.
*/
function memcpy1(string memory src, uint srcIndex, bytes memory dst, uint dstIndex) internal pure {
assembly {
mstore8(add(add(dst, 32), dstIndex), shr(248, mload(add(add(src, 32), srcIndex))))
}
}
/**
* @dev Copies a string into `dst` starting at `dstIndex` with a maximum length of `dstLen`.
* This function will not write beyond `dstLen`. However, if `dstLen` is not reached, it may write zeros beyond the length of the string.
*/
function copyString(string memory src, bytes memory dst, uint dstIndex, uint dstLen) internal pure returns (uint) {
uint srcIndex;
uint srcLen = bytes(src).length;
for (; srcLen > 31 && srcIndex < srcLen && srcIndex < dstLen - 31; srcIndex += 32) {
memcpy32(src, srcIndex, dst, dstIndex + srcIndex);
}
for (; srcIndex < srcLen && srcIndex < dstLen; ++srcIndex) {
memcpy1(src, srcIndex, dst, dstIndex + srcIndex);
}
return dstIndex + srcLen;
}
/**
* @dev Adds `str` to the end of the internal buffer.
*/
function pushToStringBuffer(StringBuffer memory self, string memory str) internal pure returns (StringBuffer memory) {
if (self.buffer.length == self.numberOfStrings) {
string[] memory newBuffer = new string[](self.buffer.length * 2);
for (uint i = 0; i < self.buffer.length; ++i) {
newBuffer[i] = self.buffer[i];
}
self.buffer = newBuffer;
}
self.buffer[self.numberOfStrings] = str;
self.numberOfStrings++;
self.totalStringLength += bytes(str).length;
return self;
}
/**
* @dev Concatenates `str` to the end of the last string in the internal buffer.
*/
function concatToLastString(StringBuffer memory self, string memory str) internal pure {
if (self.numberOfStrings == 0) {
self.numberOfStrings++;
}
uint idx = self.numberOfStrings - 1;
self.buffer[idx] = string(abi.encodePacked(self.buffer[idx], str));
self.totalStringLength += bytes(str).length;
}
/**
* @notice Creates a new empty StringBuffer
* @dev The initial capacity is 16 strings
*/
function empty() external pure returns (StringBuffer memory) {
return StringBuffer(new string[](1), 0, 0);
}
/**
* @notice Converts the contents of the StringBuffer into a string.
* @dev This runs in O(n) time.
*/
function get(StringBuffer memory self) internal pure returns (string memory) {
bytes memory output = new bytes(self.totalStringLength);
uint ptr = 0;
for (uint i = 0; i < self.numberOfStrings; ++i) {
ptr = copyString(self.buffer[i], output, ptr, self.totalStringLength);
}
return string(output);
}
/**
* @notice Appends a string to the end of the StringBuffer
* @dev Internally the StringBuffer keeps a `string[]` that doubles in size when extra capacity is needed.
*/
function append(StringBuffer memory self, string memory str) internal pure {
uint idx = self.numberOfStrings == 0 ? 0 : self.numberOfStrings - 1;
if (bytes(self.buffer[idx]).length + bytes(str).length <= 1024) {
concatToLastString(self, str);
} else {
pushToStringBuffer(self, str);
}
}
} | memcpy1 | function memcpy1(string memory src, uint srcIndex, bytes memory dst, uint dstIndex) internal pure {
assembly {
mstore8(add(add(dst, 32), dstIndex), shr(248, mload(add(add(src, 32), srcIndex))))
}
}
| /**
* @dev Copies 1 bytes of `src` at `srcIndex` into `dst` at `dstIndex`.
* This uses the same amount of gas as `memcpy32`, so prefer `memcpy32` if at all possible.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | MIT | ipfs://2641bc0a6897496103acbb493c7a9a096bcedd65afb1cb130ed46a31f4554f73 | {
"func_code_index": [
573,
811
]
} | 9,143 |
||
BitMonsters | contracts/StringBuffer.sol | 0xbd091f143ee754f1d755494441aee781d918cb93 | Solidity | StringBufferLibrary | library StringBufferLibrary {
/**
* @dev Copies 32 bytes of `src` starting at `srcIndex` into `dst` starting at `dstIndex`.
*/
function memcpy32(string memory src, uint srcIndex, bytes memory dst, uint dstIndex) internal pure {
assembly {
mstore(add(add(dst, 32), dstIndex), mload(add(add(src, 32), srcIndex)))
}
}
/**
* @dev Copies 1 bytes of `src` at `srcIndex` into `dst` at `dstIndex`.
* This uses the same amount of gas as `memcpy32`, so prefer `memcpy32` if at all possible.
*/
function memcpy1(string memory src, uint srcIndex, bytes memory dst, uint dstIndex) internal pure {
assembly {
mstore8(add(add(dst, 32), dstIndex), shr(248, mload(add(add(src, 32), srcIndex))))
}
}
/**
* @dev Copies a string into `dst` starting at `dstIndex` with a maximum length of `dstLen`.
* This function will not write beyond `dstLen`. However, if `dstLen` is not reached, it may write zeros beyond the length of the string.
*/
function copyString(string memory src, bytes memory dst, uint dstIndex, uint dstLen) internal pure returns (uint) {
uint srcIndex;
uint srcLen = bytes(src).length;
for (; srcLen > 31 && srcIndex < srcLen && srcIndex < dstLen - 31; srcIndex += 32) {
memcpy32(src, srcIndex, dst, dstIndex + srcIndex);
}
for (; srcIndex < srcLen && srcIndex < dstLen; ++srcIndex) {
memcpy1(src, srcIndex, dst, dstIndex + srcIndex);
}
return dstIndex + srcLen;
}
/**
* @dev Adds `str` to the end of the internal buffer.
*/
function pushToStringBuffer(StringBuffer memory self, string memory str) internal pure returns (StringBuffer memory) {
if (self.buffer.length == self.numberOfStrings) {
string[] memory newBuffer = new string[](self.buffer.length * 2);
for (uint i = 0; i < self.buffer.length; ++i) {
newBuffer[i] = self.buffer[i];
}
self.buffer = newBuffer;
}
self.buffer[self.numberOfStrings] = str;
self.numberOfStrings++;
self.totalStringLength += bytes(str).length;
return self;
}
/**
* @dev Concatenates `str` to the end of the last string in the internal buffer.
*/
function concatToLastString(StringBuffer memory self, string memory str) internal pure {
if (self.numberOfStrings == 0) {
self.numberOfStrings++;
}
uint idx = self.numberOfStrings - 1;
self.buffer[idx] = string(abi.encodePacked(self.buffer[idx], str));
self.totalStringLength += bytes(str).length;
}
/**
* @notice Creates a new empty StringBuffer
* @dev The initial capacity is 16 strings
*/
function empty() external pure returns (StringBuffer memory) {
return StringBuffer(new string[](1), 0, 0);
}
/**
* @notice Converts the contents of the StringBuffer into a string.
* @dev This runs in O(n) time.
*/
function get(StringBuffer memory self) internal pure returns (string memory) {
bytes memory output = new bytes(self.totalStringLength);
uint ptr = 0;
for (uint i = 0; i < self.numberOfStrings; ++i) {
ptr = copyString(self.buffer[i], output, ptr, self.totalStringLength);
}
return string(output);
}
/**
* @notice Appends a string to the end of the StringBuffer
* @dev Internally the StringBuffer keeps a `string[]` that doubles in size when extra capacity is needed.
*/
function append(StringBuffer memory self, string memory str) internal pure {
uint idx = self.numberOfStrings == 0 ? 0 : self.numberOfStrings - 1;
if (bytes(self.buffer[idx]).length + bytes(str).length <= 1024) {
concatToLastString(self, str);
} else {
pushToStringBuffer(self, str);
}
}
} | copyString | function copyString(string memory src, bytes memory dst, uint dstIndex, uint dstLen) internal pure returns (uint) {
uint srcIndex;
uint srcLen = bytes(src).length;
for (; srcLen > 31 && srcIndex < srcLen && srcIndex < dstLen - 31; srcIndex += 32) {
memcpy32(src, srcIndex, dst, dstIndex + srcIndex);
}
for (; srcIndex < srcLen && srcIndex < dstLen; ++srcIndex) {
memcpy1(src, srcIndex, dst, dstIndex + srcIndex);
}
return dstIndex + srcLen;
}
| /**
* @dev Copies a string into `dst` starting at `dstIndex` with a maximum length of `dstLen`.
* This function will not write beyond `dstLen`. However, if `dstLen` is not reached, it may write zeros beyond the length of the string.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | MIT | ipfs://2641bc0a6897496103acbb493c7a9a096bcedd65afb1cb130ed46a31f4554f73 | {
"func_code_index": [
1078,
1623
]
} | 9,144 |
||
BitMonsters | contracts/StringBuffer.sol | 0xbd091f143ee754f1d755494441aee781d918cb93 | Solidity | StringBufferLibrary | library StringBufferLibrary {
/**
* @dev Copies 32 bytes of `src` starting at `srcIndex` into `dst` starting at `dstIndex`.
*/
function memcpy32(string memory src, uint srcIndex, bytes memory dst, uint dstIndex) internal pure {
assembly {
mstore(add(add(dst, 32), dstIndex), mload(add(add(src, 32), srcIndex)))
}
}
/**
* @dev Copies 1 bytes of `src` at `srcIndex` into `dst` at `dstIndex`.
* This uses the same amount of gas as `memcpy32`, so prefer `memcpy32` if at all possible.
*/
function memcpy1(string memory src, uint srcIndex, bytes memory dst, uint dstIndex) internal pure {
assembly {
mstore8(add(add(dst, 32), dstIndex), shr(248, mload(add(add(src, 32), srcIndex))))
}
}
/**
* @dev Copies a string into `dst` starting at `dstIndex` with a maximum length of `dstLen`.
* This function will not write beyond `dstLen`. However, if `dstLen` is not reached, it may write zeros beyond the length of the string.
*/
function copyString(string memory src, bytes memory dst, uint dstIndex, uint dstLen) internal pure returns (uint) {
uint srcIndex;
uint srcLen = bytes(src).length;
for (; srcLen > 31 && srcIndex < srcLen && srcIndex < dstLen - 31; srcIndex += 32) {
memcpy32(src, srcIndex, dst, dstIndex + srcIndex);
}
for (; srcIndex < srcLen && srcIndex < dstLen; ++srcIndex) {
memcpy1(src, srcIndex, dst, dstIndex + srcIndex);
}
return dstIndex + srcLen;
}
/**
* @dev Adds `str` to the end of the internal buffer.
*/
function pushToStringBuffer(StringBuffer memory self, string memory str) internal pure returns (StringBuffer memory) {
if (self.buffer.length == self.numberOfStrings) {
string[] memory newBuffer = new string[](self.buffer.length * 2);
for (uint i = 0; i < self.buffer.length; ++i) {
newBuffer[i] = self.buffer[i];
}
self.buffer = newBuffer;
}
self.buffer[self.numberOfStrings] = str;
self.numberOfStrings++;
self.totalStringLength += bytes(str).length;
return self;
}
/**
* @dev Concatenates `str` to the end of the last string in the internal buffer.
*/
function concatToLastString(StringBuffer memory self, string memory str) internal pure {
if (self.numberOfStrings == 0) {
self.numberOfStrings++;
}
uint idx = self.numberOfStrings - 1;
self.buffer[idx] = string(abi.encodePacked(self.buffer[idx], str));
self.totalStringLength += bytes(str).length;
}
/**
* @notice Creates a new empty StringBuffer
* @dev The initial capacity is 16 strings
*/
function empty() external pure returns (StringBuffer memory) {
return StringBuffer(new string[](1), 0, 0);
}
/**
* @notice Converts the contents of the StringBuffer into a string.
* @dev This runs in O(n) time.
*/
function get(StringBuffer memory self) internal pure returns (string memory) {
bytes memory output = new bytes(self.totalStringLength);
uint ptr = 0;
for (uint i = 0; i < self.numberOfStrings; ++i) {
ptr = copyString(self.buffer[i], output, ptr, self.totalStringLength);
}
return string(output);
}
/**
* @notice Appends a string to the end of the StringBuffer
* @dev Internally the StringBuffer keeps a `string[]` that doubles in size when extra capacity is needed.
*/
function append(StringBuffer memory self, string memory str) internal pure {
uint idx = self.numberOfStrings == 0 ? 0 : self.numberOfStrings - 1;
if (bytes(self.buffer[idx]).length + bytes(str).length <= 1024) {
concatToLastString(self, str);
} else {
pushToStringBuffer(self, str);
}
}
} | pushToStringBuffer | function pushToStringBuffer(StringBuffer memory self, string memory str) internal pure returns (StringBuffer memory) {
if (self.buffer.length == self.numberOfStrings) {
string[] memory newBuffer = new string[](self.buffer.length * 2);
for (uint i = 0; i < self.buffer.length; ++i) {
newBuffer[i] = self.buffer[i];
}
self.buffer = newBuffer;
}
self.buffer[self.numberOfStrings] = str;
self.numberOfStrings++;
self.totalStringLength += bytes(str).length;
return self;
}
| /**
* @dev Adds `str` to the end of the internal buffer.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | MIT | ipfs://2641bc0a6897496103acbb493c7a9a096bcedd65afb1cb130ed46a31f4554f73 | {
"func_code_index": [
1703,
2307
]
} | 9,145 |
||
BitMonsters | contracts/StringBuffer.sol | 0xbd091f143ee754f1d755494441aee781d918cb93 | Solidity | StringBufferLibrary | library StringBufferLibrary {
/**
* @dev Copies 32 bytes of `src` starting at `srcIndex` into `dst` starting at `dstIndex`.
*/
function memcpy32(string memory src, uint srcIndex, bytes memory dst, uint dstIndex) internal pure {
assembly {
mstore(add(add(dst, 32), dstIndex), mload(add(add(src, 32), srcIndex)))
}
}
/**
* @dev Copies 1 bytes of `src` at `srcIndex` into `dst` at `dstIndex`.
* This uses the same amount of gas as `memcpy32`, so prefer `memcpy32` if at all possible.
*/
function memcpy1(string memory src, uint srcIndex, bytes memory dst, uint dstIndex) internal pure {
assembly {
mstore8(add(add(dst, 32), dstIndex), shr(248, mload(add(add(src, 32), srcIndex))))
}
}
/**
* @dev Copies a string into `dst` starting at `dstIndex` with a maximum length of `dstLen`.
* This function will not write beyond `dstLen`. However, if `dstLen` is not reached, it may write zeros beyond the length of the string.
*/
function copyString(string memory src, bytes memory dst, uint dstIndex, uint dstLen) internal pure returns (uint) {
uint srcIndex;
uint srcLen = bytes(src).length;
for (; srcLen > 31 && srcIndex < srcLen && srcIndex < dstLen - 31; srcIndex += 32) {
memcpy32(src, srcIndex, dst, dstIndex + srcIndex);
}
for (; srcIndex < srcLen && srcIndex < dstLen; ++srcIndex) {
memcpy1(src, srcIndex, dst, dstIndex + srcIndex);
}
return dstIndex + srcLen;
}
/**
* @dev Adds `str` to the end of the internal buffer.
*/
function pushToStringBuffer(StringBuffer memory self, string memory str) internal pure returns (StringBuffer memory) {
if (self.buffer.length == self.numberOfStrings) {
string[] memory newBuffer = new string[](self.buffer.length * 2);
for (uint i = 0; i < self.buffer.length; ++i) {
newBuffer[i] = self.buffer[i];
}
self.buffer = newBuffer;
}
self.buffer[self.numberOfStrings] = str;
self.numberOfStrings++;
self.totalStringLength += bytes(str).length;
return self;
}
/**
* @dev Concatenates `str` to the end of the last string in the internal buffer.
*/
function concatToLastString(StringBuffer memory self, string memory str) internal pure {
if (self.numberOfStrings == 0) {
self.numberOfStrings++;
}
uint idx = self.numberOfStrings - 1;
self.buffer[idx] = string(abi.encodePacked(self.buffer[idx], str));
self.totalStringLength += bytes(str).length;
}
/**
* @notice Creates a new empty StringBuffer
* @dev The initial capacity is 16 strings
*/
function empty() external pure returns (StringBuffer memory) {
return StringBuffer(new string[](1), 0, 0);
}
/**
* @notice Converts the contents of the StringBuffer into a string.
* @dev This runs in O(n) time.
*/
function get(StringBuffer memory self) internal pure returns (string memory) {
bytes memory output = new bytes(self.totalStringLength);
uint ptr = 0;
for (uint i = 0; i < self.numberOfStrings; ++i) {
ptr = copyString(self.buffer[i], output, ptr, self.totalStringLength);
}
return string(output);
}
/**
* @notice Appends a string to the end of the StringBuffer
* @dev Internally the StringBuffer keeps a `string[]` that doubles in size when extra capacity is needed.
*/
function append(StringBuffer memory self, string memory str) internal pure {
uint idx = self.numberOfStrings == 0 ? 0 : self.numberOfStrings - 1;
if (bytes(self.buffer[idx]).length + bytes(str).length <= 1024) {
concatToLastString(self, str);
} else {
pushToStringBuffer(self, str);
}
}
} | concatToLastString | function concatToLastString(StringBuffer memory self, string memory str) internal pure {
if (self.numberOfStrings == 0) {
self.numberOfStrings++;
}
uint idx = self.numberOfStrings - 1;
self.buffer[idx] = string(abi.encodePacked(self.buffer[idx], str));
self.totalStringLength += bytes(str).length;
}
| /**
* @dev Concatenates `str` to the end of the last string in the internal buffer.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | MIT | ipfs://2641bc0a6897496103acbb493c7a9a096bcedd65afb1cb130ed46a31f4554f73 | {
"func_code_index": [
2414,
2783
]
} | 9,146 |
||
BitMonsters | contracts/StringBuffer.sol | 0xbd091f143ee754f1d755494441aee781d918cb93 | Solidity | StringBufferLibrary | library StringBufferLibrary {
/**
* @dev Copies 32 bytes of `src` starting at `srcIndex` into `dst` starting at `dstIndex`.
*/
function memcpy32(string memory src, uint srcIndex, bytes memory dst, uint dstIndex) internal pure {
assembly {
mstore(add(add(dst, 32), dstIndex), mload(add(add(src, 32), srcIndex)))
}
}
/**
* @dev Copies 1 bytes of `src` at `srcIndex` into `dst` at `dstIndex`.
* This uses the same amount of gas as `memcpy32`, so prefer `memcpy32` if at all possible.
*/
function memcpy1(string memory src, uint srcIndex, bytes memory dst, uint dstIndex) internal pure {
assembly {
mstore8(add(add(dst, 32), dstIndex), shr(248, mload(add(add(src, 32), srcIndex))))
}
}
/**
* @dev Copies a string into `dst` starting at `dstIndex` with a maximum length of `dstLen`.
* This function will not write beyond `dstLen`. However, if `dstLen` is not reached, it may write zeros beyond the length of the string.
*/
function copyString(string memory src, bytes memory dst, uint dstIndex, uint dstLen) internal pure returns (uint) {
uint srcIndex;
uint srcLen = bytes(src).length;
for (; srcLen > 31 && srcIndex < srcLen && srcIndex < dstLen - 31; srcIndex += 32) {
memcpy32(src, srcIndex, dst, dstIndex + srcIndex);
}
for (; srcIndex < srcLen && srcIndex < dstLen; ++srcIndex) {
memcpy1(src, srcIndex, dst, dstIndex + srcIndex);
}
return dstIndex + srcLen;
}
/**
* @dev Adds `str` to the end of the internal buffer.
*/
function pushToStringBuffer(StringBuffer memory self, string memory str) internal pure returns (StringBuffer memory) {
if (self.buffer.length == self.numberOfStrings) {
string[] memory newBuffer = new string[](self.buffer.length * 2);
for (uint i = 0; i < self.buffer.length; ++i) {
newBuffer[i] = self.buffer[i];
}
self.buffer = newBuffer;
}
self.buffer[self.numberOfStrings] = str;
self.numberOfStrings++;
self.totalStringLength += bytes(str).length;
return self;
}
/**
* @dev Concatenates `str` to the end of the last string in the internal buffer.
*/
function concatToLastString(StringBuffer memory self, string memory str) internal pure {
if (self.numberOfStrings == 0) {
self.numberOfStrings++;
}
uint idx = self.numberOfStrings - 1;
self.buffer[idx] = string(abi.encodePacked(self.buffer[idx], str));
self.totalStringLength += bytes(str).length;
}
/**
* @notice Creates a new empty StringBuffer
* @dev The initial capacity is 16 strings
*/
function empty() external pure returns (StringBuffer memory) {
return StringBuffer(new string[](1), 0, 0);
}
/**
* @notice Converts the contents of the StringBuffer into a string.
* @dev This runs in O(n) time.
*/
function get(StringBuffer memory self) internal pure returns (string memory) {
bytes memory output = new bytes(self.totalStringLength);
uint ptr = 0;
for (uint i = 0; i < self.numberOfStrings; ++i) {
ptr = copyString(self.buffer[i], output, ptr, self.totalStringLength);
}
return string(output);
}
/**
* @notice Appends a string to the end of the StringBuffer
* @dev Internally the StringBuffer keeps a `string[]` that doubles in size when extra capacity is needed.
*/
function append(StringBuffer memory self, string memory str) internal pure {
uint idx = self.numberOfStrings == 0 ? 0 : self.numberOfStrings - 1;
if (bytes(self.buffer[idx]).length + bytes(str).length <= 1024) {
concatToLastString(self, str);
} else {
pushToStringBuffer(self, str);
}
}
} | empty | function empty() external pure returns (StringBuffer memory) {
return StringBuffer(new string[](1), 0, 0);
}
| /**
* @notice Creates a new empty StringBuffer
* @dev The initial capacity is 16 strings
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | MIT | ipfs://2641bc0a6897496103acbb493c7a9a096bcedd65afb1cb130ed46a31f4554f73 | {
"func_code_index": [
2901,
3028
]
} | 9,147 |
||
BitMonsters | contracts/StringBuffer.sol | 0xbd091f143ee754f1d755494441aee781d918cb93 | Solidity | StringBufferLibrary | library StringBufferLibrary {
/**
* @dev Copies 32 bytes of `src` starting at `srcIndex` into `dst` starting at `dstIndex`.
*/
function memcpy32(string memory src, uint srcIndex, bytes memory dst, uint dstIndex) internal pure {
assembly {
mstore(add(add(dst, 32), dstIndex), mload(add(add(src, 32), srcIndex)))
}
}
/**
* @dev Copies 1 bytes of `src` at `srcIndex` into `dst` at `dstIndex`.
* This uses the same amount of gas as `memcpy32`, so prefer `memcpy32` if at all possible.
*/
function memcpy1(string memory src, uint srcIndex, bytes memory dst, uint dstIndex) internal pure {
assembly {
mstore8(add(add(dst, 32), dstIndex), shr(248, mload(add(add(src, 32), srcIndex))))
}
}
/**
* @dev Copies a string into `dst` starting at `dstIndex` with a maximum length of `dstLen`.
* This function will not write beyond `dstLen`. However, if `dstLen` is not reached, it may write zeros beyond the length of the string.
*/
function copyString(string memory src, bytes memory dst, uint dstIndex, uint dstLen) internal pure returns (uint) {
uint srcIndex;
uint srcLen = bytes(src).length;
for (; srcLen > 31 && srcIndex < srcLen && srcIndex < dstLen - 31; srcIndex += 32) {
memcpy32(src, srcIndex, dst, dstIndex + srcIndex);
}
for (; srcIndex < srcLen && srcIndex < dstLen; ++srcIndex) {
memcpy1(src, srcIndex, dst, dstIndex + srcIndex);
}
return dstIndex + srcLen;
}
/**
* @dev Adds `str` to the end of the internal buffer.
*/
function pushToStringBuffer(StringBuffer memory self, string memory str) internal pure returns (StringBuffer memory) {
if (self.buffer.length == self.numberOfStrings) {
string[] memory newBuffer = new string[](self.buffer.length * 2);
for (uint i = 0; i < self.buffer.length; ++i) {
newBuffer[i] = self.buffer[i];
}
self.buffer = newBuffer;
}
self.buffer[self.numberOfStrings] = str;
self.numberOfStrings++;
self.totalStringLength += bytes(str).length;
return self;
}
/**
* @dev Concatenates `str` to the end of the last string in the internal buffer.
*/
function concatToLastString(StringBuffer memory self, string memory str) internal pure {
if (self.numberOfStrings == 0) {
self.numberOfStrings++;
}
uint idx = self.numberOfStrings - 1;
self.buffer[idx] = string(abi.encodePacked(self.buffer[idx], str));
self.totalStringLength += bytes(str).length;
}
/**
* @notice Creates a new empty StringBuffer
* @dev The initial capacity is 16 strings
*/
function empty() external pure returns (StringBuffer memory) {
return StringBuffer(new string[](1), 0, 0);
}
/**
* @notice Converts the contents of the StringBuffer into a string.
* @dev This runs in O(n) time.
*/
function get(StringBuffer memory self) internal pure returns (string memory) {
bytes memory output = new bytes(self.totalStringLength);
uint ptr = 0;
for (uint i = 0; i < self.numberOfStrings; ++i) {
ptr = copyString(self.buffer[i], output, ptr, self.totalStringLength);
}
return string(output);
}
/**
* @notice Appends a string to the end of the StringBuffer
* @dev Internally the StringBuffer keeps a `string[]` that doubles in size when extra capacity is needed.
*/
function append(StringBuffer memory self, string memory str) internal pure {
uint idx = self.numberOfStrings == 0 ? 0 : self.numberOfStrings - 1;
if (bytes(self.buffer[idx]).length + bytes(str).length <= 1024) {
concatToLastString(self, str);
} else {
pushToStringBuffer(self, str);
}
}
} | get | function get(StringBuffer memory self) internal pure returns (string memory) {
bytes memory output = new bytes(self.totalStringLength);
uint ptr = 0;
for (uint i = 0; i < self.numberOfStrings; ++i) {
ptr = copyString(self.buffer[i], output, ptr, self.totalStringLength);
}
return string(output);
}
| /**
* @notice Converts the contents of the StringBuffer into a string.
* @dev This runs in O(n) time.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | MIT | ipfs://2641bc0a6897496103acbb493c7a9a096bcedd65afb1cb130ed46a31f4554f73 | {
"func_code_index": [
3159,
3528
]
} | 9,148 |
||
BitMonsters | contracts/StringBuffer.sol | 0xbd091f143ee754f1d755494441aee781d918cb93 | Solidity | StringBufferLibrary | library StringBufferLibrary {
/**
* @dev Copies 32 bytes of `src` starting at `srcIndex` into `dst` starting at `dstIndex`.
*/
function memcpy32(string memory src, uint srcIndex, bytes memory dst, uint dstIndex) internal pure {
assembly {
mstore(add(add(dst, 32), dstIndex), mload(add(add(src, 32), srcIndex)))
}
}
/**
* @dev Copies 1 bytes of `src` at `srcIndex` into `dst` at `dstIndex`.
* This uses the same amount of gas as `memcpy32`, so prefer `memcpy32` if at all possible.
*/
function memcpy1(string memory src, uint srcIndex, bytes memory dst, uint dstIndex) internal pure {
assembly {
mstore8(add(add(dst, 32), dstIndex), shr(248, mload(add(add(src, 32), srcIndex))))
}
}
/**
* @dev Copies a string into `dst` starting at `dstIndex` with a maximum length of `dstLen`.
* This function will not write beyond `dstLen`. However, if `dstLen` is not reached, it may write zeros beyond the length of the string.
*/
function copyString(string memory src, bytes memory dst, uint dstIndex, uint dstLen) internal pure returns (uint) {
uint srcIndex;
uint srcLen = bytes(src).length;
for (; srcLen > 31 && srcIndex < srcLen && srcIndex < dstLen - 31; srcIndex += 32) {
memcpy32(src, srcIndex, dst, dstIndex + srcIndex);
}
for (; srcIndex < srcLen && srcIndex < dstLen; ++srcIndex) {
memcpy1(src, srcIndex, dst, dstIndex + srcIndex);
}
return dstIndex + srcLen;
}
/**
* @dev Adds `str` to the end of the internal buffer.
*/
function pushToStringBuffer(StringBuffer memory self, string memory str) internal pure returns (StringBuffer memory) {
if (self.buffer.length == self.numberOfStrings) {
string[] memory newBuffer = new string[](self.buffer.length * 2);
for (uint i = 0; i < self.buffer.length; ++i) {
newBuffer[i] = self.buffer[i];
}
self.buffer = newBuffer;
}
self.buffer[self.numberOfStrings] = str;
self.numberOfStrings++;
self.totalStringLength += bytes(str).length;
return self;
}
/**
* @dev Concatenates `str` to the end of the last string in the internal buffer.
*/
function concatToLastString(StringBuffer memory self, string memory str) internal pure {
if (self.numberOfStrings == 0) {
self.numberOfStrings++;
}
uint idx = self.numberOfStrings - 1;
self.buffer[idx] = string(abi.encodePacked(self.buffer[idx], str));
self.totalStringLength += bytes(str).length;
}
/**
* @notice Creates a new empty StringBuffer
* @dev The initial capacity is 16 strings
*/
function empty() external pure returns (StringBuffer memory) {
return StringBuffer(new string[](1), 0, 0);
}
/**
* @notice Converts the contents of the StringBuffer into a string.
* @dev This runs in O(n) time.
*/
function get(StringBuffer memory self) internal pure returns (string memory) {
bytes memory output = new bytes(self.totalStringLength);
uint ptr = 0;
for (uint i = 0; i < self.numberOfStrings; ++i) {
ptr = copyString(self.buffer[i], output, ptr, self.totalStringLength);
}
return string(output);
}
/**
* @notice Appends a string to the end of the StringBuffer
* @dev Internally the StringBuffer keeps a `string[]` that doubles in size when extra capacity is needed.
*/
function append(StringBuffer memory self, string memory str) internal pure {
uint idx = self.numberOfStrings == 0 ? 0 : self.numberOfStrings - 1;
if (bytes(self.buffer[idx]).length + bytes(str).length <= 1024) {
concatToLastString(self, str);
} else {
pushToStringBuffer(self, str);
}
}
} | append | function append(StringBuffer memory self, string memory str) internal pure {
uint idx = self.numberOfStrings == 0 ? 0 : self.numberOfStrings - 1;
if (bytes(self.buffer[idx]).length + bytes(str).length <= 1024) {
concatToLastString(self, str);
} else {
pushToStringBuffer(self, str);
}
}
| /**
* @notice Appends a string to the end of the StringBuffer
* @dev Internally the StringBuffer keeps a `string[]` that doubles in size when extra capacity is needed.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | MIT | ipfs://2641bc0a6897496103acbb493c7a9a096bcedd65afb1cb130ed46a31f4554f73 | {
"func_code_index": [
3725,
4083
]
} | 9,149 |
||
BitMonsters | contracts/BitMonstersAddon.sol | 0xbd091f143ee754f1d755494441aee781d918cb93 | Solidity | BitMonstersAddon | abstract contract BitMonstersAddon is Ownable {
IBitMonsters internal bitMonsters;
modifier onlyAdmin() {
require(bitMonsters.isAdmin(msg.sender), "admins only");
_;
}
modifier ownsToken(uint tokenId) {
require(bitMonsters.ownerOf(tokenId) == msg.sender, "you don't own this shit");
_;
}
/**
* @notice This must be called before the Brainz contract can be used.
*
* @dev Within the BitMonsters contract, call initializeBrainz().
*/
function setBitMonstersContract(IBitMonsters _contract) external onlyOwner {
bitMonsters = _contract;
}
} | /**
* @title A contract should inherit this if it provides functionality for the Bit Monsters contract.
*/ | NatSpecMultiLine | setBitMonstersContract | function setBitMonstersContract(IBitMonsters _contract) external onlyOwner {
bitMonsters = _contract;
}
| /**
* @notice This must be called before the Brainz contract can be used.
*
* @dev Within the BitMonsters contract, call initializeBrainz().
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | MIT | ipfs://2641bc0a6897496103acbb493c7a9a096bcedd65afb1cb130ed46a31f4554f73 | {
"func_code_index": [
529,
651
]
} | 9,150 |
Sav3rToken | @openzeppelin/contracts/utils/EnumerableSet.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | EnumerableSet | library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping (bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) { // Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
// When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
// so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.
bytes32 lastvalue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastvalue;
// Update the index for the moved value
set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
require(set._values.length > index, "EnumerableSet: index out of bounds");
return set._values[index];
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(value)));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint256(_at(set._inner, index)));
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
} | /**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.0.0, only sets of type `address` (`AddressSet`) and `uint256`
* (`UintSet`) are supported.
*/ | NatSpecMultiLine | _add | function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
| /**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
908,
1327
]
} | 9,151 |
Sav3rToken | @openzeppelin/contracts/utils/EnumerableSet.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | EnumerableSet | library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping (bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) { // Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
// When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
// so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.
bytes32 lastvalue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastvalue;
// Update the index for the moved value
set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
require(set._values.length > index, "EnumerableSet: index out of bounds");
return set._values[index];
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(value)));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint256(_at(set._inner, index)));
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
} | /**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.0.0, only sets of type `address` (`AddressSet`) and `uint256`
* (`UintSet`) are supported.
*/ | NatSpecMultiLine | _remove | function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) { // Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
// When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
// so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.
bytes32 lastvalue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastvalue;
// Update the index for the moved value
set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
| /**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
1498,
3047
]
} | 9,152 |
Sav3rToken | @openzeppelin/contracts/utils/EnumerableSet.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | EnumerableSet | library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping (bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) { // Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
// When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
// so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.
bytes32 lastvalue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastvalue;
// Update the index for the moved value
set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
require(set._values.length > index, "EnumerableSet: index out of bounds");
return set._values[index];
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(value)));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint256(_at(set._inner, index)));
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
} | /**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.0.0, only sets of type `address` (`AddressSet`) and `uint256`
* (`UintSet`) are supported.
*/ | NatSpecMultiLine | _contains | function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
| /**
* @dev Returns true if the value is in the set. O(1).
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
3128,
3262
]
} | 9,153 |
Sav3rToken | @openzeppelin/contracts/utils/EnumerableSet.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | EnumerableSet | library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping (bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) { // Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
// When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
// so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.
bytes32 lastvalue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastvalue;
// Update the index for the moved value
set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
require(set._values.length > index, "EnumerableSet: index out of bounds");
return set._values[index];
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(value)));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint256(_at(set._inner, index)));
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
} | /**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.0.0, only sets of type `address` (`AddressSet`) and `uint256`
* (`UintSet`) are supported.
*/ | NatSpecMultiLine | _length | function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
| /**
* @dev Returns the number of values on the set. O(1).
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
3343,
3457
]
} | 9,154 |
Sav3rToken | @openzeppelin/contracts/utils/EnumerableSet.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | EnumerableSet | library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping (bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) { // Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
// When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
// so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.
bytes32 lastvalue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastvalue;
// Update the index for the moved value
set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
require(set._values.length > index, "EnumerableSet: index out of bounds");
return set._values[index];
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(value)));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint256(_at(set._inner, index)));
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
} | /**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.0.0, only sets of type `address` (`AddressSet`) and `uint256`
* (`UintSet`) are supported.
*/ | NatSpecMultiLine | _at | function _at(Set storage set, uint256 index) private view returns (bytes32) {
require(set._values.length > index, "EnumerableSet: index out of bounds");
return set._values[index];
}
| /**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
3796,
4005
]
} | 9,155 |
Sav3rToken | @openzeppelin/contracts/utils/EnumerableSet.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | EnumerableSet | library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping (bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) { // Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
// When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
// so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.
bytes32 lastvalue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastvalue;
// Update the index for the moved value
set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
require(set._values.length > index, "EnumerableSet: index out of bounds");
return set._values[index];
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(value)));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint256(_at(set._inner, index)));
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
} | /**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.0.0, only sets of type `address` (`AddressSet`) and `uint256`
* (`UintSet`) are supported.
*/ | NatSpecMultiLine | add | function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(value)));
}
| /**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
4254,
4402
]
} | 9,156 |
Sav3rToken | @openzeppelin/contracts/utils/EnumerableSet.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | EnumerableSet | library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping (bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) { // Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
// When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
// so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.
bytes32 lastvalue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastvalue;
// Update the index for the moved value
set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
require(set._values.length > index, "EnumerableSet: index out of bounds");
return set._values[index];
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(value)));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint256(_at(set._inner, index)));
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
} | /**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.0.0, only sets of type `address` (`AddressSet`) and `uint256`
* (`UintSet`) are supported.
*/ | NatSpecMultiLine | remove | function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(value)));
}
| /**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
4573,
4727
]
} | 9,157 |
Sav3rToken | @openzeppelin/contracts/utils/EnumerableSet.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | EnumerableSet | library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping (bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) { // Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
// When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
// so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.
bytes32 lastvalue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastvalue;
// Update the index for the moved value
set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
require(set._values.length > index, "EnumerableSet: index out of bounds");
return set._values[index];
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(value)));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint256(_at(set._inner, index)));
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
} | /**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.0.0, only sets of type `address` (`AddressSet`) and `uint256`
* (`UintSet`) are supported.
*/ | NatSpecMultiLine | contains | function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(value)));
}
| /**
* @dev Returns true if the value is in the set. O(1).
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
4808,
4971
]
} | 9,158 |
Sav3rToken | @openzeppelin/contracts/utils/EnumerableSet.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | EnumerableSet | library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping (bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) { // Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
// When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
// so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.
bytes32 lastvalue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastvalue;
// Update the index for the moved value
set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
require(set._values.length > index, "EnumerableSet: index out of bounds");
return set._values[index];
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(value)));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint256(_at(set._inner, index)));
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
} | /**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.0.0, only sets of type `address` (`AddressSet`) and `uint256`
* (`UintSet`) are supported.
*/ | NatSpecMultiLine | length | function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
| /**
* @dev Returns the number of values in the set. O(1).
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
5052,
5174
]
} | 9,159 |
Sav3rToken | @openzeppelin/contracts/utils/EnumerableSet.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | EnumerableSet | library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping (bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) { // Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
// When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
// so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.
bytes32 lastvalue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastvalue;
// Update the index for the moved value
set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
require(set._values.length > index, "EnumerableSet: index out of bounds");
return set._values[index];
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(value)));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint256(_at(set._inner, index)));
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
} | /**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.0.0, only sets of type `address` (`AddressSet`) and `uint256`
* (`UintSet`) are supported.
*/ | NatSpecMultiLine | at | function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint256(_at(set._inner, index)));
}
| /**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
5513,
5667
]
} | 9,160 |
Sav3rToken | @openzeppelin/contracts/utils/EnumerableSet.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | EnumerableSet | library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping (bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) { // Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
// When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
// so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.
bytes32 lastvalue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastvalue;
// Update the index for the moved value
set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
require(set._values.length > index, "EnumerableSet: index out of bounds");
return set._values[index];
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(value)));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint256(_at(set._inner, index)));
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
} | /**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.0.0, only sets of type `address` (`AddressSet`) and `uint256`
* (`UintSet`) are supported.
*/ | NatSpecMultiLine | add | function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
| /**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
5912,
6048
]
} | 9,161 |
Sav3rToken | @openzeppelin/contracts/utils/EnumerableSet.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | EnumerableSet | library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping (bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) { // Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
// When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
// so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.
bytes32 lastvalue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastvalue;
// Update the index for the moved value
set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
require(set._values.length > index, "EnumerableSet: index out of bounds");
return set._values[index];
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(value)));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint256(_at(set._inner, index)));
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
} | /**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.0.0, only sets of type `address` (`AddressSet`) and `uint256`
* (`UintSet`) are supported.
*/ | NatSpecMultiLine | remove | function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
| /**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
6219,
6361
]
} | 9,162 |
Sav3rToken | @openzeppelin/contracts/utils/EnumerableSet.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | EnumerableSet | library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping (bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) { // Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
// When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
// so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.
bytes32 lastvalue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastvalue;
// Update the index for the moved value
set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
require(set._values.length > index, "EnumerableSet: index out of bounds");
return set._values[index];
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(value)));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint256(_at(set._inner, index)));
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
} | /**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.0.0, only sets of type `address` (`AddressSet`) and `uint256`
* (`UintSet`) are supported.
*/ | NatSpecMultiLine | contains | function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
| /**
* @dev Returns true if the value is in the set. O(1).
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
6442,
6593
]
} | 9,163 |
Sav3rToken | @openzeppelin/contracts/utils/EnumerableSet.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | EnumerableSet | library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping (bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) { // Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
// When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
// so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.
bytes32 lastvalue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastvalue;
// Update the index for the moved value
set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
require(set._values.length > index, "EnumerableSet: index out of bounds");
return set._values[index];
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(value)));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint256(_at(set._inner, index)));
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
} | /**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.0.0, only sets of type `address` (`AddressSet`) and `uint256`
* (`UintSet`) are supported.
*/ | NatSpecMultiLine | length | function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
| /**
* @dev Returns the number of values on the set. O(1).
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
6674,
6793
]
} | 9,164 |
Sav3rToken | @openzeppelin/contracts/utils/EnumerableSet.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | EnumerableSet | library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping (bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) { // Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
// When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
// so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.
bytes32 lastvalue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastvalue;
// Update the index for the moved value
set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
require(set._values.length > index, "EnumerableSet: index out of bounds");
return set._values[index];
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(value)));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint256(_at(set._inner, index)));
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
} | /**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.0.0, only sets of type `address` (`AddressSet`) and `uint256`
* (`UintSet`) are supported.
*/ | NatSpecMultiLine | at | function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
| /**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
7132,
7274
]
} | 9,165 |
Sav3rToken | @openzeppelin/contracts/utils/EnumerableSet.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | AccessControl | abstract contract AccessControl is Context {
using EnumerableSet for EnumerableSet.AddressSet;
using Address for address;
struct RoleData {
EnumerableSet.AddressSet members;
bytes32 adminRole;
}
mapping (bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view returns (bool) {
return _roles[role].members.contains(account);
}
/**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/
function getRoleMemberCount(bytes32 role) public view returns (uint256) {
return _roles[role].members.length();
}
/**
* @dev Returns one of the accounts that have `role`. `index` must be a
* value between 0 and {getRoleMemberCount}, non-inclusive.
*
* Role bearers are not sorted in any particular way, and their ordering may
* change at any point.
*
*/
function getRoleMember(bytes32 role, uint256 index) public view returns (address) {
return _roles[role].members.at(index);
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) public virtual {
require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant");
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) public virtual {
require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke");
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) public virtual {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event. Note that unlike {grantRole}, this function doesn't perform any
* checks on the calling account.
*
* [WARNING]
* ====
* This function should only be called from the constructor when setting
* up the initial roles for the system.
*
* Using this function in any other way is effectively circumventing the admin
* system imposed by {AccessControl}.
* ====
*/
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
_roles[role].adminRole = adminRole;
}
function _grantRole(bytes32 role, address account) private {
if (_roles[role].members.add(account)) {
emit RoleGranted(role, account, _msgSender());
}
}
function _revokeRole(bytes32 role, address account) private {
if (_roles[role].members.remove(account)) {
emit RoleRevoked(role, account, _msgSender());
}
}
} | /**
* @dev Contract module that allows children to implement role-based access
* control mechanisms.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```
* function foo() public {
* require(hasRole(MY_ROLE, _msgSender()));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*/ | NatSpecMultiLine | hasRole | function hasRole(bytes32 role, address account) public view returns (bool) {
return _roles[role].members.contains(account);
}
| /**
* @dev Returns `true` if `account` has been granted `role`.
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
1123,
1267
]
} | 9,166 |
Sav3rToken | @openzeppelin/contracts/utils/EnumerableSet.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | AccessControl | abstract contract AccessControl is Context {
using EnumerableSet for EnumerableSet.AddressSet;
using Address for address;
struct RoleData {
EnumerableSet.AddressSet members;
bytes32 adminRole;
}
mapping (bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view returns (bool) {
return _roles[role].members.contains(account);
}
/**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/
function getRoleMemberCount(bytes32 role) public view returns (uint256) {
return _roles[role].members.length();
}
/**
* @dev Returns one of the accounts that have `role`. `index` must be a
* value between 0 and {getRoleMemberCount}, non-inclusive.
*
* Role bearers are not sorted in any particular way, and their ordering may
* change at any point.
*
*/
function getRoleMember(bytes32 role, uint256 index) public view returns (address) {
return _roles[role].members.at(index);
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) public virtual {
require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant");
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) public virtual {
require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke");
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) public virtual {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event. Note that unlike {grantRole}, this function doesn't perform any
* checks on the calling account.
*
* [WARNING]
* ====
* This function should only be called from the constructor when setting
* up the initial roles for the system.
*
* Using this function in any other way is effectively circumventing the admin
* system imposed by {AccessControl}.
* ====
*/
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
_roles[role].adminRole = adminRole;
}
function _grantRole(bytes32 role, address account) private {
if (_roles[role].members.add(account)) {
emit RoleGranted(role, account, _msgSender());
}
}
function _revokeRole(bytes32 role, address account) private {
if (_roles[role].members.remove(account)) {
emit RoleRevoked(role, account, _msgSender());
}
}
} | /**
* @dev Contract module that allows children to implement role-based access
* control mechanisms.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```
* function foo() public {
* require(hasRole(MY_ROLE, _msgSender()));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*/ | NatSpecMultiLine | getRoleMemberCount | function getRoleMemberCount(bytes32 role) public view returns (uint256) {
return _roles[role].members.length();
}
| /**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
1436,
1568
]
} | 9,167 |
Sav3rToken | @openzeppelin/contracts/utils/EnumerableSet.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | AccessControl | abstract contract AccessControl is Context {
using EnumerableSet for EnumerableSet.AddressSet;
using Address for address;
struct RoleData {
EnumerableSet.AddressSet members;
bytes32 adminRole;
}
mapping (bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view returns (bool) {
return _roles[role].members.contains(account);
}
/**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/
function getRoleMemberCount(bytes32 role) public view returns (uint256) {
return _roles[role].members.length();
}
/**
* @dev Returns one of the accounts that have `role`. `index` must be a
* value between 0 and {getRoleMemberCount}, non-inclusive.
*
* Role bearers are not sorted in any particular way, and their ordering may
* change at any point.
*
*/
function getRoleMember(bytes32 role, uint256 index) public view returns (address) {
return _roles[role].members.at(index);
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) public virtual {
require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant");
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) public virtual {
require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke");
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) public virtual {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event. Note that unlike {grantRole}, this function doesn't perform any
* checks on the calling account.
*
* [WARNING]
* ====
* This function should only be called from the constructor when setting
* up the initial roles for the system.
*
* Using this function in any other way is effectively circumventing the admin
* system imposed by {AccessControl}.
* ====
*/
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
_roles[role].adminRole = adminRole;
}
function _grantRole(bytes32 role, address account) private {
if (_roles[role].members.add(account)) {
emit RoleGranted(role, account, _msgSender());
}
}
function _revokeRole(bytes32 role, address account) private {
if (_roles[role].members.remove(account)) {
emit RoleRevoked(role, account, _msgSender());
}
}
} | /**
* @dev Contract module that allows children to implement role-based access
* control mechanisms.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```
* function foo() public {
* require(hasRole(MY_ROLE, _msgSender()));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*/ | NatSpecMultiLine | getRoleMember | function getRoleMember(bytes32 role, uint256 index) public view returns (address) {
return _roles[role].members.at(index);
}
| /**
* @dev Returns one of the accounts that have `role`. `index` must be a
* value between 0 and {getRoleMemberCount}, non-inclusive.
*
* Role bearers are not sorted in any particular way, and their ordering may
* change at any point.
*
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
1858,
2001
]
} | 9,168 |
Sav3rToken | @openzeppelin/contracts/utils/EnumerableSet.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | AccessControl | abstract contract AccessControl is Context {
using EnumerableSet for EnumerableSet.AddressSet;
using Address for address;
struct RoleData {
EnumerableSet.AddressSet members;
bytes32 adminRole;
}
mapping (bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view returns (bool) {
return _roles[role].members.contains(account);
}
/**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/
function getRoleMemberCount(bytes32 role) public view returns (uint256) {
return _roles[role].members.length();
}
/**
* @dev Returns one of the accounts that have `role`. `index` must be a
* value between 0 and {getRoleMemberCount}, non-inclusive.
*
* Role bearers are not sorted in any particular way, and their ordering may
* change at any point.
*
*/
function getRoleMember(bytes32 role, uint256 index) public view returns (address) {
return _roles[role].members.at(index);
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) public virtual {
require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant");
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) public virtual {
require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke");
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) public virtual {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event. Note that unlike {grantRole}, this function doesn't perform any
* checks on the calling account.
*
* [WARNING]
* ====
* This function should only be called from the constructor when setting
* up the initial roles for the system.
*
* Using this function in any other way is effectively circumventing the admin
* system imposed by {AccessControl}.
* ====
*/
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
_roles[role].adminRole = adminRole;
}
function _grantRole(bytes32 role, address account) private {
if (_roles[role].members.add(account)) {
emit RoleGranted(role, account, _msgSender());
}
}
function _revokeRole(bytes32 role, address account) private {
if (_roles[role].members.remove(account)) {
emit RoleRevoked(role, account, _msgSender());
}
}
} | /**
* @dev Contract module that allows children to implement role-based access
* control mechanisms.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```
* function foo() public {
* require(hasRole(MY_ROLE, _msgSender()));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*/ | NatSpecMultiLine | getRoleAdmin | function getRoleAdmin(bytes32 role) public view returns (bytes32) {
return _roles[role].adminRole;
}
| /**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
2185,
2304
]
} | 9,169 |
Sav3rToken | @openzeppelin/contracts/utils/EnumerableSet.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | AccessControl | abstract contract AccessControl is Context {
using EnumerableSet for EnumerableSet.AddressSet;
using Address for address;
struct RoleData {
EnumerableSet.AddressSet members;
bytes32 adminRole;
}
mapping (bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view returns (bool) {
return _roles[role].members.contains(account);
}
/**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/
function getRoleMemberCount(bytes32 role) public view returns (uint256) {
return _roles[role].members.length();
}
/**
* @dev Returns one of the accounts that have `role`. `index` must be a
* value between 0 and {getRoleMemberCount}, non-inclusive.
*
* Role bearers are not sorted in any particular way, and their ordering may
* change at any point.
*
*/
function getRoleMember(bytes32 role, uint256 index) public view returns (address) {
return _roles[role].members.at(index);
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) public virtual {
require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant");
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) public virtual {
require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke");
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) public virtual {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event. Note that unlike {grantRole}, this function doesn't perform any
* checks on the calling account.
*
* [WARNING]
* ====
* This function should only be called from the constructor when setting
* up the initial roles for the system.
*
* Using this function in any other way is effectively circumventing the admin
* system imposed by {AccessControl}.
* ====
*/
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
_roles[role].adminRole = adminRole;
}
function _grantRole(bytes32 role, address account) private {
if (_roles[role].members.add(account)) {
emit RoleGranted(role, account, _msgSender());
}
}
function _revokeRole(bytes32 role, address account) private {
if (_roles[role].members.remove(account)) {
emit RoleRevoked(role, account, _msgSender());
}
}
} | /**
* @dev Contract module that allows children to implement role-based access
* control mechanisms.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```
* function foo() public {
* require(hasRole(MY_ROLE, _msgSender()));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*/ | NatSpecMultiLine | grantRole | function grantRole(bytes32 role, address account) public virtual {
require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant");
_grantRole(role, account);
}
| /**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
2561,
2793
]
} | 9,170 |
Sav3rToken | @openzeppelin/contracts/utils/EnumerableSet.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | AccessControl | abstract contract AccessControl is Context {
using EnumerableSet for EnumerableSet.AddressSet;
using Address for address;
struct RoleData {
EnumerableSet.AddressSet members;
bytes32 adminRole;
}
mapping (bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view returns (bool) {
return _roles[role].members.contains(account);
}
/**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/
function getRoleMemberCount(bytes32 role) public view returns (uint256) {
return _roles[role].members.length();
}
/**
* @dev Returns one of the accounts that have `role`. `index` must be a
* value between 0 and {getRoleMemberCount}, non-inclusive.
*
* Role bearers are not sorted in any particular way, and their ordering may
* change at any point.
*
*/
function getRoleMember(bytes32 role, uint256 index) public view returns (address) {
return _roles[role].members.at(index);
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) public virtual {
require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant");
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) public virtual {
require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke");
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) public virtual {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event. Note that unlike {grantRole}, this function doesn't perform any
* checks on the calling account.
*
* [WARNING]
* ====
* This function should only be called from the constructor when setting
* up the initial roles for the system.
*
* Using this function in any other way is effectively circumventing the admin
* system imposed by {AccessControl}.
* ====
*/
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
_roles[role].adminRole = adminRole;
}
function _grantRole(bytes32 role, address account) private {
if (_roles[role].members.add(account)) {
emit RoleGranted(role, account, _msgSender());
}
}
function _revokeRole(bytes32 role, address account) private {
if (_roles[role].members.remove(account)) {
emit RoleRevoked(role, account, _msgSender());
}
}
} | /**
* @dev Contract module that allows children to implement role-based access
* control mechanisms.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```
* function foo() public {
* require(hasRole(MY_ROLE, _msgSender()));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*/ | NatSpecMultiLine | revokeRole | function revokeRole(bytes32 role, address account) public virtual {
require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke");
_revokeRole(role, account);
}
| /**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
3033,
3268
]
} | 9,171 |
Sav3rToken | @openzeppelin/contracts/utils/EnumerableSet.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | AccessControl | abstract contract AccessControl is Context {
using EnumerableSet for EnumerableSet.AddressSet;
using Address for address;
struct RoleData {
EnumerableSet.AddressSet members;
bytes32 adminRole;
}
mapping (bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view returns (bool) {
return _roles[role].members.contains(account);
}
/**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/
function getRoleMemberCount(bytes32 role) public view returns (uint256) {
return _roles[role].members.length();
}
/**
* @dev Returns one of the accounts that have `role`. `index` must be a
* value between 0 and {getRoleMemberCount}, non-inclusive.
*
* Role bearers are not sorted in any particular way, and their ordering may
* change at any point.
*
*/
function getRoleMember(bytes32 role, uint256 index) public view returns (address) {
return _roles[role].members.at(index);
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) public virtual {
require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant");
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) public virtual {
require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke");
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) public virtual {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event. Note that unlike {grantRole}, this function doesn't perform any
* checks on the calling account.
*
* [WARNING]
* ====
* This function should only be called from the constructor when setting
* up the initial roles for the system.
*
* Using this function in any other way is effectively circumventing the admin
* system imposed by {AccessControl}.
* ====
*/
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
_roles[role].adminRole = adminRole;
}
function _grantRole(bytes32 role, address account) private {
if (_roles[role].members.add(account)) {
emit RoleGranted(role, account, _msgSender());
}
}
function _revokeRole(bytes32 role, address account) private {
if (_roles[role].members.remove(account)) {
emit RoleRevoked(role, account, _msgSender());
}
}
} | /**
* @dev Contract module that allows children to implement role-based access
* control mechanisms.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```
* function foo() public {
* require(hasRole(MY_ROLE, _msgSender()));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*/ | NatSpecMultiLine | renounceRole | function renounceRole(bytes32 role, address account) public virtual {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
| /**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
3770,
3984
]
} | 9,172 |
Sav3rToken | @openzeppelin/contracts/utils/EnumerableSet.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | AccessControl | abstract contract AccessControl is Context {
using EnumerableSet for EnumerableSet.AddressSet;
using Address for address;
struct RoleData {
EnumerableSet.AddressSet members;
bytes32 adminRole;
}
mapping (bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view returns (bool) {
return _roles[role].members.contains(account);
}
/**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/
function getRoleMemberCount(bytes32 role) public view returns (uint256) {
return _roles[role].members.length();
}
/**
* @dev Returns one of the accounts that have `role`. `index` must be a
* value between 0 and {getRoleMemberCount}, non-inclusive.
*
* Role bearers are not sorted in any particular way, and their ordering may
* change at any point.
*
*/
function getRoleMember(bytes32 role, uint256 index) public view returns (address) {
return _roles[role].members.at(index);
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) public virtual {
require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant");
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) public virtual {
require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke");
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) public virtual {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event. Note that unlike {grantRole}, this function doesn't perform any
* checks on the calling account.
*
* [WARNING]
* ====
* This function should only be called from the constructor when setting
* up the initial roles for the system.
*
* Using this function in any other way is effectively circumventing the admin
* system imposed by {AccessControl}.
* ====
*/
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
_roles[role].adminRole = adminRole;
}
function _grantRole(bytes32 role, address account) private {
if (_roles[role].members.add(account)) {
emit RoleGranted(role, account, _msgSender());
}
}
function _revokeRole(bytes32 role, address account) private {
if (_roles[role].members.remove(account)) {
emit RoleRevoked(role, account, _msgSender());
}
}
} | /**
* @dev Contract module that allows children to implement role-based access
* control mechanisms.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```
* function foo() public {
* require(hasRole(MY_ROLE, _msgSender()));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*/ | NatSpecMultiLine | _setupRole | function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
| /**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event. Note that unlike {grantRole}, this function doesn't perform any
* checks on the calling account.
*
* [WARNING]
* ====
* This function should only be called from the constructor when setting
* up the initial roles for the system.
*
* Using this function in any other way is effectively circumventing the admin
* system imposed by {AccessControl}.
* ====
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
4562,
4679
]
} | 9,173 |
Sav3rToken | @openzeppelin/contracts/utils/EnumerableSet.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | AccessControl | abstract contract AccessControl is Context {
using EnumerableSet for EnumerableSet.AddressSet;
using Address for address;
struct RoleData {
EnumerableSet.AddressSet members;
bytes32 adminRole;
}
mapping (bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view returns (bool) {
return _roles[role].members.contains(account);
}
/**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/
function getRoleMemberCount(bytes32 role) public view returns (uint256) {
return _roles[role].members.length();
}
/**
* @dev Returns one of the accounts that have `role`. `index` must be a
* value between 0 and {getRoleMemberCount}, non-inclusive.
*
* Role bearers are not sorted in any particular way, and their ordering may
* change at any point.
*
*/
function getRoleMember(bytes32 role, uint256 index) public view returns (address) {
return _roles[role].members.at(index);
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) public virtual {
require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant");
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) public virtual {
require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke");
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) public virtual {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event. Note that unlike {grantRole}, this function doesn't perform any
* checks on the calling account.
*
* [WARNING]
* ====
* This function should only be called from the constructor when setting
* up the initial roles for the system.
*
* Using this function in any other way is effectively circumventing the admin
* system imposed by {AccessControl}.
* ====
*/
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
_roles[role].adminRole = adminRole;
}
function _grantRole(bytes32 role, address account) private {
if (_roles[role].members.add(account)) {
emit RoleGranted(role, account, _msgSender());
}
}
function _revokeRole(bytes32 role, address account) private {
if (_roles[role].members.remove(account)) {
emit RoleRevoked(role, account, _msgSender());
}
}
} | /**
* @dev Contract module that allows children to implement role-based access
* control mechanisms.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```
* function foo() public {
* require(hasRole(MY_ROLE, _msgSender()));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*/ | NatSpecMultiLine | _setRoleAdmin | function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
_roles[role].adminRole = adminRole;
}
| /**
* @dev Sets `adminRole` as ``role``'s admin role.
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
4756,
4887
]
} | 9,174 |
Sav3rToken | @openzeppelin/contracts/utils/EnumerableSet.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | Sav3rToken | contract Sav3rToken is ERC20Capped, ERC20Burnable, ERC1363, Roles, TokenRecover {
// indicates if transfer is enabled
bool private _transferEnabled = true;
string public constant BUILT_ON = "https://vittominacori.github.io/erc20-generator";
/**
* @dev Emitted during transfer enabling
*/
event TransferEnabled();
/**
* @dev Tokens can be moved only after if transfer enabled or if you are an approved operator.
*/
modifier canTransfer(address from) {
require(
_transferEnabled || hasRole(OPERATOR_ROLE, from),
"BaseToken: transfer is not enabled or from does not have the OPERATOR role"
);
_;
}
/**
* @param name Name of the token
* @param symbol A symbol to be used as ticker
* @param decimals Number of decimals. All the operations are done using the smallest and indivisible token unit
*/
constructor(
string memory name,
string memory symbol,
uint8 decimals,
uint256 cap
)
public
ERC20Capped(cap)
ERC1363(name, symbol)
{
_setupDecimals(decimals);
}
/**
* @dev Transfer tokens to a specified address.
* @param to The address to transfer to
* @param value The amount to be transferred
* @return A boolean that indicates if the operation was successful.
*/
function transfer(address to, uint256 value) public virtual override(ERC20) canTransfer(_msgSender()) returns (bool) {
return super.transfer(to, value);
}
/**
* @dev Transfer tokens from one address to another.
* @param from The address which you want to send tokens from
* @param to The address which you want to transfer to
* @param value the amount of tokens to be transferred
* @return A boolean that indicates if the operation was successful.
*/
function transferFrom(address from, address to, uint256 value) public virtual override(ERC20) canTransfer(from) returns (bool) {
return super.transferFrom(from, to, value);
}
/**
* @dev See {ERC20-_beforeTokenTransfer}.
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override(ERC20, ERC20Capped) {
super._beforeTokenTransfer(from, to, amount);
}
} | transfer | function transfer(address to, uint256 value) public virtual override(ERC20) canTransfer(_msgSender()) returns (bool) {
return super.transfer(to, value);
}
| /**
* @dev Transfer tokens to a specified address.
* @param to The address to transfer to
* @param value The amount to be transferred
* @return A boolean that indicates if the operation was successful.
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
1473,
1646
]
} | 9,175 |
||
Sav3rToken | @openzeppelin/contracts/utils/EnumerableSet.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | Sav3rToken | contract Sav3rToken is ERC20Capped, ERC20Burnable, ERC1363, Roles, TokenRecover {
// indicates if transfer is enabled
bool private _transferEnabled = true;
string public constant BUILT_ON = "https://vittominacori.github.io/erc20-generator";
/**
* @dev Emitted during transfer enabling
*/
event TransferEnabled();
/**
* @dev Tokens can be moved only after if transfer enabled or if you are an approved operator.
*/
modifier canTransfer(address from) {
require(
_transferEnabled || hasRole(OPERATOR_ROLE, from),
"BaseToken: transfer is not enabled or from does not have the OPERATOR role"
);
_;
}
/**
* @param name Name of the token
* @param symbol A symbol to be used as ticker
* @param decimals Number of decimals. All the operations are done using the smallest and indivisible token unit
*/
constructor(
string memory name,
string memory symbol,
uint8 decimals,
uint256 cap
)
public
ERC20Capped(cap)
ERC1363(name, symbol)
{
_setupDecimals(decimals);
}
/**
* @dev Transfer tokens to a specified address.
* @param to The address to transfer to
* @param value The amount to be transferred
* @return A boolean that indicates if the operation was successful.
*/
function transfer(address to, uint256 value) public virtual override(ERC20) canTransfer(_msgSender()) returns (bool) {
return super.transfer(to, value);
}
/**
* @dev Transfer tokens from one address to another.
* @param from The address which you want to send tokens from
* @param to The address which you want to transfer to
* @param value the amount of tokens to be transferred
* @return A boolean that indicates if the operation was successful.
*/
function transferFrom(address from, address to, uint256 value) public virtual override(ERC20) canTransfer(from) returns (bool) {
return super.transferFrom(from, to, value);
}
/**
* @dev See {ERC20-_beforeTokenTransfer}.
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override(ERC20, ERC20Capped) {
super._beforeTokenTransfer(from, to, amount);
}
} | transferFrom | function transferFrom(address from, address to, uint256 value) public virtual override(ERC20) canTransfer(from) returns (bool) {
return super.transferFrom(from, to, value);
}
| /**
* @dev Transfer tokens from one address to another.
* @param from The address which you want to send tokens from
* @param to The address which you want to transfer to
* @param value the amount of tokens to be transferred
* @return A boolean that indicates if the operation was successful.
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
1986,
2179
]
} | 9,176 |
||
Sav3rToken | @openzeppelin/contracts/utils/EnumerableSet.sol | 0xdf8ab83a6e4b868d140808810b0875fd1cdc2417 | Solidity | Sav3rToken | contract Sav3rToken is ERC20Capped, ERC20Burnable, ERC1363, Roles, TokenRecover {
// indicates if transfer is enabled
bool private _transferEnabled = true;
string public constant BUILT_ON = "https://vittominacori.github.io/erc20-generator";
/**
* @dev Emitted during transfer enabling
*/
event TransferEnabled();
/**
* @dev Tokens can be moved only after if transfer enabled or if you are an approved operator.
*/
modifier canTransfer(address from) {
require(
_transferEnabled || hasRole(OPERATOR_ROLE, from),
"BaseToken: transfer is not enabled or from does not have the OPERATOR role"
);
_;
}
/**
* @param name Name of the token
* @param symbol A symbol to be used as ticker
* @param decimals Number of decimals. All the operations are done using the smallest and indivisible token unit
*/
constructor(
string memory name,
string memory symbol,
uint8 decimals,
uint256 cap
)
public
ERC20Capped(cap)
ERC1363(name, symbol)
{
_setupDecimals(decimals);
}
/**
* @dev Transfer tokens to a specified address.
* @param to The address to transfer to
* @param value The amount to be transferred
* @return A boolean that indicates if the operation was successful.
*/
function transfer(address to, uint256 value) public virtual override(ERC20) canTransfer(_msgSender()) returns (bool) {
return super.transfer(to, value);
}
/**
* @dev Transfer tokens from one address to another.
* @param from The address which you want to send tokens from
* @param to The address which you want to transfer to
* @param value the amount of tokens to be transferred
* @return A boolean that indicates if the operation was successful.
*/
function transferFrom(address from, address to, uint256 value) public virtual override(ERC20) canTransfer(from) returns (bool) {
return super.transferFrom(from, to, value);
}
/**
* @dev See {ERC20-_beforeTokenTransfer}.
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override(ERC20, ERC20Capped) {
super._beforeTokenTransfer(from, to, amount);
}
} | _beforeTokenTransfer | function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override(ERC20, ERC20Capped) {
super._beforeTokenTransfer(from, to, amount);
}
| /**
* @dev See {ERC20-_beforeTokenTransfer}.
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://bd9f25ef5c0cf1d46d370fb69975c73f1d94d239b458419fafdef7a417fc2d71 | {
"func_code_index": [
2247,
2433
]
} | 9,177 |
||
BitMonsters | contracts/Brainz.sol | 0xbd091f143ee754f1d755494441aee781d918cb93 | Solidity | Brainz | contract Brainz is ERC20Burnable, BitMonstersAddon {
using RngLibrary for Rng;
mapping (uint => uint) public tokenIdToTimestamp;
Rng private rng = RngLibrary.newRng();
constructor() ERC20("Brainz", "BRAINZ") {
}
function adminMint(address addr, uint256 count) external onlyAdmin {
_mint(addr, count * 1 ether);
}
function adminBurn(address addr, uint256 count) external onlyAdmin {
_burn(addr, count * 1 ether);
}
/**
* Claims all Brainz from all staked Bit Monsters the caller owns.
*/
function claimBrainz() external {
uint count = bitMonsters.balanceOf(msg.sender);
uint total = 0;
for (uint i = 0; i < count; ++i) {
uint tokenId = bitMonsters.tokenOfOwnerByIndex(msg.sender, i);
uint rewards = calculateRewards(tokenId);
if (rewards > 0) {
tokenIdToTimestamp[tokenId] = block.timestamp - ((block.timestamp - tokenIdToTimestamp[tokenId]) % 86400);
}
total += rewards;
}
_mint(msg.sender, total);
}
function rewardRate(BitMonster memory m) public pure returns (uint) {
return ((m.genesis ? 2 : 1) * (m.special != Special.NONE ? 2 : 1) + (m.superYield ? 1 : 0)) * 1 ether;
}
/**
* Returns the amount of pending Brainz the caller can currently claim.
*/
function calculateRewards(uint tokenId) public view returns (uint) {
BitMonster memory m = bitMonsters.getBitMonster(tokenId);
uint nDays = (block.timestamp - tokenIdToTimestamp[tokenId]) / 86400;
return rewardRate(m) * nDays;
}
/**
* Tracks the Bit Monster with the given tokenId for reward calculation.
*/
function register(uint tokenId) external onlyAdmin {
require(tokenIdToTimestamp[tokenId] == 0, "already staked");
tokenIdToTimestamp[tokenId] = block.timestamp;
}
/**
* Stake your Brainz a-la OSRS Duel Arena.
*
* 50% chance of multiplying your Brainz by 1.9x rounded up.
* 50% chance of losing everything you stake.
*/
function stake(uint count) external returns (bool won) {
require(count > 0, "Must stake at least one BRAINZ");
require(balanceOf(msg.sender) >= count, "You don't have that many tokens");
Rng memory rn = rng;
if (rn.generate(0, 1) == 0) {
_mint(msg.sender, (count - count / 10) * 1 ether);
won = true;
}
else {
_burn(msg.sender, count * 1 ether);
won = false;
}
rng = rn;
}
} | /**
* @title The contract for the Brainz token and staking. At the moment, these can only be obtained by staking Bit Monsters.
*/ | NatSpecMultiLine | claimBrainz | function claimBrainz() external {
uint count = bitMonsters.balanceOf(msg.sender);
uint total = 0;
for (uint i = 0; i < count; ++i) {
uint tokenId = bitMonsters.tokenOfOwnerByIndex(msg.sender, i);
uint rewards = calculateRewards(tokenId);
if (rewards > 0) {
tokenIdToTimestamp[tokenId] = block.timestamp - ((block.timestamp - tokenIdToTimestamp[tokenId]) % 86400);
}
total += rewards;
}
_mint(msg.sender, total);
}
| /**
* Claims all Brainz from all staked Bit Monsters the caller owns.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | MIT | ipfs://2641bc0a6897496103acbb493c7a9a096bcedd65afb1cb130ed46a31f4554f73 | {
"func_code_index": [
578,
1132
]
} | 9,178 |
BitMonsters | contracts/Brainz.sol | 0xbd091f143ee754f1d755494441aee781d918cb93 | Solidity | Brainz | contract Brainz is ERC20Burnable, BitMonstersAddon {
using RngLibrary for Rng;
mapping (uint => uint) public tokenIdToTimestamp;
Rng private rng = RngLibrary.newRng();
constructor() ERC20("Brainz", "BRAINZ") {
}
function adminMint(address addr, uint256 count) external onlyAdmin {
_mint(addr, count * 1 ether);
}
function adminBurn(address addr, uint256 count) external onlyAdmin {
_burn(addr, count * 1 ether);
}
/**
* Claims all Brainz from all staked Bit Monsters the caller owns.
*/
function claimBrainz() external {
uint count = bitMonsters.balanceOf(msg.sender);
uint total = 0;
for (uint i = 0; i < count; ++i) {
uint tokenId = bitMonsters.tokenOfOwnerByIndex(msg.sender, i);
uint rewards = calculateRewards(tokenId);
if (rewards > 0) {
tokenIdToTimestamp[tokenId] = block.timestamp - ((block.timestamp - tokenIdToTimestamp[tokenId]) % 86400);
}
total += rewards;
}
_mint(msg.sender, total);
}
function rewardRate(BitMonster memory m) public pure returns (uint) {
return ((m.genesis ? 2 : 1) * (m.special != Special.NONE ? 2 : 1) + (m.superYield ? 1 : 0)) * 1 ether;
}
/**
* Returns the amount of pending Brainz the caller can currently claim.
*/
function calculateRewards(uint tokenId) public view returns (uint) {
BitMonster memory m = bitMonsters.getBitMonster(tokenId);
uint nDays = (block.timestamp - tokenIdToTimestamp[tokenId]) / 86400;
return rewardRate(m) * nDays;
}
/**
* Tracks the Bit Monster with the given tokenId for reward calculation.
*/
function register(uint tokenId) external onlyAdmin {
require(tokenIdToTimestamp[tokenId] == 0, "already staked");
tokenIdToTimestamp[tokenId] = block.timestamp;
}
/**
* Stake your Brainz a-la OSRS Duel Arena.
*
* 50% chance of multiplying your Brainz by 1.9x rounded up.
* 50% chance of losing everything you stake.
*/
function stake(uint count) external returns (bool won) {
require(count > 0, "Must stake at least one BRAINZ");
require(balanceOf(msg.sender) >= count, "You don't have that many tokens");
Rng memory rn = rng;
if (rn.generate(0, 1) == 0) {
_mint(msg.sender, (count - count / 10) * 1 ether);
won = true;
}
else {
_burn(msg.sender, count * 1 ether);
won = false;
}
rng = rn;
}
} | /**
* @title The contract for the Brainz token and staking. At the moment, these can only be obtained by staking Bit Monsters.
*/ | NatSpecMultiLine | calculateRewards | function calculateRewards(uint tokenId) public view returns (uint) {
BitMonster memory m = bitMonsters.getBitMonster(tokenId);
uint nDays = (block.timestamp - tokenIdToTimestamp[tokenId]) / 86400;
return rewardRate(m) * nDays;
}
| /**
* Returns the amount of pending Brainz the caller can currently claim.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | MIT | ipfs://2641bc0a6897496103acbb493c7a9a096bcedd65afb1cb130ed46a31f4554f73 | {
"func_code_index": [
1426,
1693
]
} | 9,179 |
BitMonsters | contracts/Brainz.sol | 0xbd091f143ee754f1d755494441aee781d918cb93 | Solidity | Brainz | contract Brainz is ERC20Burnable, BitMonstersAddon {
using RngLibrary for Rng;
mapping (uint => uint) public tokenIdToTimestamp;
Rng private rng = RngLibrary.newRng();
constructor() ERC20("Brainz", "BRAINZ") {
}
function adminMint(address addr, uint256 count) external onlyAdmin {
_mint(addr, count * 1 ether);
}
function adminBurn(address addr, uint256 count) external onlyAdmin {
_burn(addr, count * 1 ether);
}
/**
* Claims all Brainz from all staked Bit Monsters the caller owns.
*/
function claimBrainz() external {
uint count = bitMonsters.balanceOf(msg.sender);
uint total = 0;
for (uint i = 0; i < count; ++i) {
uint tokenId = bitMonsters.tokenOfOwnerByIndex(msg.sender, i);
uint rewards = calculateRewards(tokenId);
if (rewards > 0) {
tokenIdToTimestamp[tokenId] = block.timestamp - ((block.timestamp - tokenIdToTimestamp[tokenId]) % 86400);
}
total += rewards;
}
_mint(msg.sender, total);
}
function rewardRate(BitMonster memory m) public pure returns (uint) {
return ((m.genesis ? 2 : 1) * (m.special != Special.NONE ? 2 : 1) + (m.superYield ? 1 : 0)) * 1 ether;
}
/**
* Returns the amount of pending Brainz the caller can currently claim.
*/
function calculateRewards(uint tokenId) public view returns (uint) {
BitMonster memory m = bitMonsters.getBitMonster(tokenId);
uint nDays = (block.timestamp - tokenIdToTimestamp[tokenId]) / 86400;
return rewardRate(m) * nDays;
}
/**
* Tracks the Bit Monster with the given tokenId for reward calculation.
*/
function register(uint tokenId) external onlyAdmin {
require(tokenIdToTimestamp[tokenId] == 0, "already staked");
tokenIdToTimestamp[tokenId] = block.timestamp;
}
/**
* Stake your Brainz a-la OSRS Duel Arena.
*
* 50% chance of multiplying your Brainz by 1.9x rounded up.
* 50% chance of losing everything you stake.
*/
function stake(uint count) external returns (bool won) {
require(count > 0, "Must stake at least one BRAINZ");
require(balanceOf(msg.sender) >= count, "You don't have that many tokens");
Rng memory rn = rng;
if (rn.generate(0, 1) == 0) {
_mint(msg.sender, (count - count / 10) * 1 ether);
won = true;
}
else {
_burn(msg.sender, count * 1 ether);
won = false;
}
rng = rn;
}
} | /**
* @title The contract for the Brainz token and staking. At the moment, these can only be obtained by staking Bit Monsters.
*/ | NatSpecMultiLine | register | function register(uint tokenId) external onlyAdmin {
require(tokenIdToTimestamp[tokenId] == 0, "already staked");
tokenIdToTimestamp[tokenId] = block.timestamp;
}
| /**
* Tracks the Bit Monster with the given tokenId for reward calculation.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | MIT | ipfs://2641bc0a6897496103acbb493c7a9a096bcedd65afb1cb130ed46a31f4554f73 | {
"func_code_index": [
1792,
1982
]
} | 9,180 |
BitMonsters | contracts/Brainz.sol | 0xbd091f143ee754f1d755494441aee781d918cb93 | Solidity | Brainz | contract Brainz is ERC20Burnable, BitMonstersAddon {
using RngLibrary for Rng;
mapping (uint => uint) public tokenIdToTimestamp;
Rng private rng = RngLibrary.newRng();
constructor() ERC20("Brainz", "BRAINZ") {
}
function adminMint(address addr, uint256 count) external onlyAdmin {
_mint(addr, count * 1 ether);
}
function adminBurn(address addr, uint256 count) external onlyAdmin {
_burn(addr, count * 1 ether);
}
/**
* Claims all Brainz from all staked Bit Monsters the caller owns.
*/
function claimBrainz() external {
uint count = bitMonsters.balanceOf(msg.sender);
uint total = 0;
for (uint i = 0; i < count; ++i) {
uint tokenId = bitMonsters.tokenOfOwnerByIndex(msg.sender, i);
uint rewards = calculateRewards(tokenId);
if (rewards > 0) {
tokenIdToTimestamp[tokenId] = block.timestamp - ((block.timestamp - tokenIdToTimestamp[tokenId]) % 86400);
}
total += rewards;
}
_mint(msg.sender, total);
}
function rewardRate(BitMonster memory m) public pure returns (uint) {
return ((m.genesis ? 2 : 1) * (m.special != Special.NONE ? 2 : 1) + (m.superYield ? 1 : 0)) * 1 ether;
}
/**
* Returns the amount of pending Brainz the caller can currently claim.
*/
function calculateRewards(uint tokenId) public view returns (uint) {
BitMonster memory m = bitMonsters.getBitMonster(tokenId);
uint nDays = (block.timestamp - tokenIdToTimestamp[tokenId]) / 86400;
return rewardRate(m) * nDays;
}
/**
* Tracks the Bit Monster with the given tokenId for reward calculation.
*/
function register(uint tokenId) external onlyAdmin {
require(tokenIdToTimestamp[tokenId] == 0, "already staked");
tokenIdToTimestamp[tokenId] = block.timestamp;
}
/**
* Stake your Brainz a-la OSRS Duel Arena.
*
* 50% chance of multiplying your Brainz by 1.9x rounded up.
* 50% chance of losing everything you stake.
*/
function stake(uint count) external returns (bool won) {
require(count > 0, "Must stake at least one BRAINZ");
require(balanceOf(msg.sender) >= count, "You don't have that many tokens");
Rng memory rn = rng;
if (rn.generate(0, 1) == 0) {
_mint(msg.sender, (count - count / 10) * 1 ether);
won = true;
}
else {
_burn(msg.sender, count * 1 ether);
won = false;
}
rng = rn;
}
} | /**
* @title The contract for the Brainz token and staking. At the moment, these can only be obtained by staking Bit Monsters.
*/ | NatSpecMultiLine | stake | function stake(uint count) external returns (bool won) {
require(count > 0, "Must stake at least one BRAINZ");
require(balanceOf(msg.sender) >= count, "You don't have that many tokens");
Rng memory rn = rng;
if (rn.generate(0, 1) == 0) {
_mint(msg.sender, (count - count / 10) * 1 ether);
won = true;
}
else {
_burn(msg.sender, count * 1 ether);
won = false;
}
rng = rn;
}
| /**
* Stake your Brainz a-la OSRS Duel Arena.
*
* 50% chance of multiplying your Brainz by 1.9x rounded up.
* 50% chance of losing everything you stake.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | MIT | ipfs://2641bc0a6897496103acbb493c7a9a096bcedd65afb1cb130ed46a31f4554f73 | {
"func_code_index": [
2176,
2688
]
} | 9,181 |
AquaToken | AquaToken.sol | 0x1d97bccc6296aac6f0be796c7e8cb270eca4c6c6 | Solidity | LibCLLu | library LibCLLu {
string constant public VERSION = "LibCLLu 0.4.0";
uint constant NULL = 0;
uint constant HEAD = 0;
bool constant PREV = false;
bool constant NEXT = true;
struct CLL{
mapping (uint => mapping (bool => uint)) cll;
}
// n: node id d: direction r: return node id
// Return existential state of a node. n == HEAD returns list existence.
function exists(CLL storage self, uint n)
internal
constant returns (bool)
{
if (self.cll[n][PREV] != HEAD || self.cll[n][NEXT] != HEAD)
return true;
if (n == HEAD)
return false;
if (self.cll[HEAD][NEXT] == n)
return true;
return false;
}
// Returns the number of elements in the list
function sizeOf(CLL storage self) internal constant returns (uint r) {
uint i = step(self, HEAD, NEXT);
while (i != HEAD) {
i = step(self, i, NEXT);
r++;
}
return;
}
// Returns the links of a node as and array
function getNode(CLL storage self, uint n)
internal constant returns (uint[2])
{
return [self.cll[n][PREV], self.cll[n][NEXT]];
}
// Returns the link of a node `n` in direction `d`.
function step(CLL storage self, uint n, bool d)
internal constant returns (uint)
{
return self.cll[n][d];
}
// Can be used before `insert` to build an ordered list
// `a` an existing node to search from, e.g. HEAD.
// `b` value to seek
// `r` first node beyond `b` in direction `d`
function seek(CLL storage self, uint a, uint b, bool d)
internal constant returns (uint r)
{
r = step(self, a, d);
while ((b!=r) && ((b < r) != d)) r = self.cll[r][d];
return;
}
// Creates a bidirectional link between two nodes on direction `d`
function stitch(CLL storage self, uint a, uint b, bool d) internal {
self.cll[b][!d] = a;
self.cll[a][d] = b;
}
// Insert node `b` beside existing node `a` in direction `d`.
function insert (CLL storage self, uint a, uint b, bool d) internal {
uint c = self.cll[a][d];
stitch (self, a, b, d);
stitch (self, b, c, d);
}
function remove(CLL storage self, uint n) internal returns (uint) {
if (n == NULL) return;
stitch(self, self.cll[n][PREV], self.cll[n][NEXT], NEXT);
delete self.cll[n][PREV];
delete self.cll[n][NEXT];
return n;
}
function push(CLL storage self, uint n, bool d) internal {
insert(self, HEAD, n, d);
}
function pop(CLL storage self, bool d) internal returns (uint) {
return remove(self, step(self, HEAD, d));
}
} | // LibCLL using `uint` keys | LineComment | exists | function exists(CLL storage self, uint n)
internal
constant returns (bool)
{
if (self.cll[n][PREV] != HEAD || self.cll[n][NEXT] != HEAD)
return true;
if (n == HEAD)
return false;
if (self.cll[HEAD][NEXT] == n)
return true;
return false;
}
| // n: node id d: direction r: return node id
// Return existential state of a node. n == HEAD returns list existence. | LineComment | v0.4.20+commit.3155dd80 | bzzr://373bce966b5a3a64cb5cee60e45ef2089d4f385eea83351e825cfda31d420536 | {
"func_code_index": [
418,
764
]
} | 9,182 |
|
AquaToken | AquaToken.sol | 0x1d97bccc6296aac6f0be796c7e8cb270eca4c6c6 | Solidity | LibCLLu | library LibCLLu {
string constant public VERSION = "LibCLLu 0.4.0";
uint constant NULL = 0;
uint constant HEAD = 0;
bool constant PREV = false;
bool constant NEXT = true;
struct CLL{
mapping (uint => mapping (bool => uint)) cll;
}
// n: node id d: direction r: return node id
// Return existential state of a node. n == HEAD returns list existence.
function exists(CLL storage self, uint n)
internal
constant returns (bool)
{
if (self.cll[n][PREV] != HEAD || self.cll[n][NEXT] != HEAD)
return true;
if (n == HEAD)
return false;
if (self.cll[HEAD][NEXT] == n)
return true;
return false;
}
// Returns the number of elements in the list
function sizeOf(CLL storage self) internal constant returns (uint r) {
uint i = step(self, HEAD, NEXT);
while (i != HEAD) {
i = step(self, i, NEXT);
r++;
}
return;
}
// Returns the links of a node as and array
function getNode(CLL storage self, uint n)
internal constant returns (uint[2])
{
return [self.cll[n][PREV], self.cll[n][NEXT]];
}
// Returns the link of a node `n` in direction `d`.
function step(CLL storage self, uint n, bool d)
internal constant returns (uint)
{
return self.cll[n][d];
}
// Can be used before `insert` to build an ordered list
// `a` an existing node to search from, e.g. HEAD.
// `b` value to seek
// `r` first node beyond `b` in direction `d`
function seek(CLL storage self, uint a, uint b, bool d)
internal constant returns (uint r)
{
r = step(self, a, d);
while ((b!=r) && ((b < r) != d)) r = self.cll[r][d];
return;
}
// Creates a bidirectional link between two nodes on direction `d`
function stitch(CLL storage self, uint a, uint b, bool d) internal {
self.cll[b][!d] = a;
self.cll[a][d] = b;
}
// Insert node `b` beside existing node `a` in direction `d`.
function insert (CLL storage self, uint a, uint b, bool d) internal {
uint c = self.cll[a][d];
stitch (self, a, b, d);
stitch (self, b, c, d);
}
function remove(CLL storage self, uint n) internal returns (uint) {
if (n == NULL) return;
stitch(self, self.cll[n][PREV], self.cll[n][NEXT], NEXT);
delete self.cll[n][PREV];
delete self.cll[n][NEXT];
return n;
}
function push(CLL storage self, uint n, bool d) internal {
insert(self, HEAD, n, d);
}
function pop(CLL storage self, bool d) internal returns (uint) {
return remove(self, step(self, HEAD, d));
}
} | // LibCLL using `uint` keys | LineComment | sizeOf | function sizeOf(CLL storage self) internal constant returns (uint r) {
uint i = step(self, HEAD, NEXT);
while (i != HEAD) {
i = step(self, i, NEXT);
r++;
}
return;
}
| // Returns the number of elements in the list | LineComment | v0.4.20+commit.3155dd80 | bzzr://373bce966b5a3a64cb5cee60e45ef2089d4f385eea83351e825cfda31d420536 | {
"func_code_index": [
822,
1059
]
} | 9,183 |
|
AquaToken | AquaToken.sol | 0x1d97bccc6296aac6f0be796c7e8cb270eca4c6c6 | Solidity | LibCLLu | library LibCLLu {
string constant public VERSION = "LibCLLu 0.4.0";
uint constant NULL = 0;
uint constant HEAD = 0;
bool constant PREV = false;
bool constant NEXT = true;
struct CLL{
mapping (uint => mapping (bool => uint)) cll;
}
// n: node id d: direction r: return node id
// Return existential state of a node. n == HEAD returns list existence.
function exists(CLL storage self, uint n)
internal
constant returns (bool)
{
if (self.cll[n][PREV] != HEAD || self.cll[n][NEXT] != HEAD)
return true;
if (n == HEAD)
return false;
if (self.cll[HEAD][NEXT] == n)
return true;
return false;
}
// Returns the number of elements in the list
function sizeOf(CLL storage self) internal constant returns (uint r) {
uint i = step(self, HEAD, NEXT);
while (i != HEAD) {
i = step(self, i, NEXT);
r++;
}
return;
}
// Returns the links of a node as and array
function getNode(CLL storage self, uint n)
internal constant returns (uint[2])
{
return [self.cll[n][PREV], self.cll[n][NEXT]];
}
// Returns the link of a node `n` in direction `d`.
function step(CLL storage self, uint n, bool d)
internal constant returns (uint)
{
return self.cll[n][d];
}
// Can be used before `insert` to build an ordered list
// `a` an existing node to search from, e.g. HEAD.
// `b` value to seek
// `r` first node beyond `b` in direction `d`
function seek(CLL storage self, uint a, uint b, bool d)
internal constant returns (uint r)
{
r = step(self, a, d);
while ((b!=r) && ((b < r) != d)) r = self.cll[r][d];
return;
}
// Creates a bidirectional link between two nodes on direction `d`
function stitch(CLL storage self, uint a, uint b, bool d) internal {
self.cll[b][!d] = a;
self.cll[a][d] = b;
}
// Insert node `b` beside existing node `a` in direction `d`.
function insert (CLL storage self, uint a, uint b, bool d) internal {
uint c = self.cll[a][d];
stitch (self, a, b, d);
stitch (self, b, c, d);
}
function remove(CLL storage self, uint n) internal returns (uint) {
if (n == NULL) return;
stitch(self, self.cll[n][PREV], self.cll[n][NEXT], NEXT);
delete self.cll[n][PREV];
delete self.cll[n][NEXT];
return n;
}
function push(CLL storage self, uint n, bool d) internal {
insert(self, HEAD, n, d);
}
function pop(CLL storage self, bool d) internal returns (uint) {
return remove(self, step(self, HEAD, d));
}
} | // LibCLL using `uint` keys | LineComment | getNode | function getNode(CLL storage self, uint n)
internal constant returns (uint[2])
{
return [self.cll[n][PREV], self.cll[n][NEXT]];
}
| // Returns the links of a node as and array | LineComment | v0.4.20+commit.3155dd80 | bzzr://373bce966b5a3a64cb5cee60e45ef2089d4f385eea83351e825cfda31d420536 | {
"func_code_index": [
1111,
1274
]
} | 9,184 |
|
AquaToken | AquaToken.sol | 0x1d97bccc6296aac6f0be796c7e8cb270eca4c6c6 | Solidity | LibCLLu | library LibCLLu {
string constant public VERSION = "LibCLLu 0.4.0";
uint constant NULL = 0;
uint constant HEAD = 0;
bool constant PREV = false;
bool constant NEXT = true;
struct CLL{
mapping (uint => mapping (bool => uint)) cll;
}
// n: node id d: direction r: return node id
// Return existential state of a node. n == HEAD returns list existence.
function exists(CLL storage self, uint n)
internal
constant returns (bool)
{
if (self.cll[n][PREV] != HEAD || self.cll[n][NEXT] != HEAD)
return true;
if (n == HEAD)
return false;
if (self.cll[HEAD][NEXT] == n)
return true;
return false;
}
// Returns the number of elements in the list
function sizeOf(CLL storage self) internal constant returns (uint r) {
uint i = step(self, HEAD, NEXT);
while (i != HEAD) {
i = step(self, i, NEXT);
r++;
}
return;
}
// Returns the links of a node as and array
function getNode(CLL storage self, uint n)
internal constant returns (uint[2])
{
return [self.cll[n][PREV], self.cll[n][NEXT]];
}
// Returns the link of a node `n` in direction `d`.
function step(CLL storage self, uint n, bool d)
internal constant returns (uint)
{
return self.cll[n][d];
}
// Can be used before `insert` to build an ordered list
// `a` an existing node to search from, e.g. HEAD.
// `b` value to seek
// `r` first node beyond `b` in direction `d`
function seek(CLL storage self, uint a, uint b, bool d)
internal constant returns (uint r)
{
r = step(self, a, d);
while ((b!=r) && ((b < r) != d)) r = self.cll[r][d];
return;
}
// Creates a bidirectional link between two nodes on direction `d`
function stitch(CLL storage self, uint a, uint b, bool d) internal {
self.cll[b][!d] = a;
self.cll[a][d] = b;
}
// Insert node `b` beside existing node `a` in direction `d`.
function insert (CLL storage self, uint a, uint b, bool d) internal {
uint c = self.cll[a][d];
stitch (self, a, b, d);
stitch (self, b, c, d);
}
function remove(CLL storage self, uint n) internal returns (uint) {
if (n == NULL) return;
stitch(self, self.cll[n][PREV], self.cll[n][NEXT], NEXT);
delete self.cll[n][PREV];
delete self.cll[n][NEXT];
return n;
}
function push(CLL storage self, uint n, bool d) internal {
insert(self, HEAD, n, d);
}
function pop(CLL storage self, bool d) internal returns (uint) {
return remove(self, step(self, HEAD, d));
}
} | // LibCLL using `uint` keys | LineComment | step | function step(CLL storage self, uint n, bool d)
internal constant returns (uint)
{
return self.cll[n][d];
}
| // Returns the link of a node `n` in direction `d`. | LineComment | v0.4.20+commit.3155dd80 | bzzr://373bce966b5a3a64cb5cee60e45ef2089d4f385eea83351e825cfda31d420536 | {
"func_code_index": [
1334,
1475
]
} | 9,185 |
|
AquaToken | AquaToken.sol | 0x1d97bccc6296aac6f0be796c7e8cb270eca4c6c6 | Solidity | LibCLLu | library LibCLLu {
string constant public VERSION = "LibCLLu 0.4.0";
uint constant NULL = 0;
uint constant HEAD = 0;
bool constant PREV = false;
bool constant NEXT = true;
struct CLL{
mapping (uint => mapping (bool => uint)) cll;
}
// n: node id d: direction r: return node id
// Return existential state of a node. n == HEAD returns list existence.
function exists(CLL storage self, uint n)
internal
constant returns (bool)
{
if (self.cll[n][PREV] != HEAD || self.cll[n][NEXT] != HEAD)
return true;
if (n == HEAD)
return false;
if (self.cll[HEAD][NEXT] == n)
return true;
return false;
}
// Returns the number of elements in the list
function sizeOf(CLL storage self) internal constant returns (uint r) {
uint i = step(self, HEAD, NEXT);
while (i != HEAD) {
i = step(self, i, NEXT);
r++;
}
return;
}
// Returns the links of a node as and array
function getNode(CLL storage self, uint n)
internal constant returns (uint[2])
{
return [self.cll[n][PREV], self.cll[n][NEXT]];
}
// Returns the link of a node `n` in direction `d`.
function step(CLL storage self, uint n, bool d)
internal constant returns (uint)
{
return self.cll[n][d];
}
// Can be used before `insert` to build an ordered list
// `a` an existing node to search from, e.g. HEAD.
// `b` value to seek
// `r` first node beyond `b` in direction `d`
function seek(CLL storage self, uint a, uint b, bool d)
internal constant returns (uint r)
{
r = step(self, a, d);
while ((b!=r) && ((b < r) != d)) r = self.cll[r][d];
return;
}
// Creates a bidirectional link between two nodes on direction `d`
function stitch(CLL storage self, uint a, uint b, bool d) internal {
self.cll[b][!d] = a;
self.cll[a][d] = b;
}
// Insert node `b` beside existing node `a` in direction `d`.
function insert (CLL storage self, uint a, uint b, bool d) internal {
uint c = self.cll[a][d];
stitch (self, a, b, d);
stitch (self, b, c, d);
}
function remove(CLL storage self, uint n) internal returns (uint) {
if (n == NULL) return;
stitch(self, self.cll[n][PREV], self.cll[n][NEXT], NEXT);
delete self.cll[n][PREV];
delete self.cll[n][NEXT];
return n;
}
function push(CLL storage self, uint n, bool d) internal {
insert(self, HEAD, n, d);
}
function pop(CLL storage self, bool d) internal returns (uint) {
return remove(self, step(self, HEAD, d));
}
} | // LibCLL using `uint` keys | LineComment | seek | function seek(CLL storage self, uint a, uint b, bool d)
internal constant returns (uint r)
{
r = step(self, a, d);
while ((b!=r) && ((b < r) != d)) r = self.cll[r][d];
return;
}
| // Can be used before `insert` to build an ordered list
// `a` an existing node to search from, e.g. HEAD.
// `b` value to seek
// `r` first node beyond `b` in direction `d` | LineComment | v0.4.20+commit.3155dd80 | bzzr://373bce966b5a3a64cb5cee60e45ef2089d4f385eea83351e825cfda31d420536 | {
"func_code_index": [
1672,
1902
]
} | 9,186 |
|
AquaToken | AquaToken.sol | 0x1d97bccc6296aac6f0be796c7e8cb270eca4c6c6 | Solidity | LibCLLu | library LibCLLu {
string constant public VERSION = "LibCLLu 0.4.0";
uint constant NULL = 0;
uint constant HEAD = 0;
bool constant PREV = false;
bool constant NEXT = true;
struct CLL{
mapping (uint => mapping (bool => uint)) cll;
}
// n: node id d: direction r: return node id
// Return existential state of a node. n == HEAD returns list existence.
function exists(CLL storage self, uint n)
internal
constant returns (bool)
{
if (self.cll[n][PREV] != HEAD || self.cll[n][NEXT] != HEAD)
return true;
if (n == HEAD)
return false;
if (self.cll[HEAD][NEXT] == n)
return true;
return false;
}
// Returns the number of elements in the list
function sizeOf(CLL storage self) internal constant returns (uint r) {
uint i = step(self, HEAD, NEXT);
while (i != HEAD) {
i = step(self, i, NEXT);
r++;
}
return;
}
// Returns the links of a node as and array
function getNode(CLL storage self, uint n)
internal constant returns (uint[2])
{
return [self.cll[n][PREV], self.cll[n][NEXT]];
}
// Returns the link of a node `n` in direction `d`.
function step(CLL storage self, uint n, bool d)
internal constant returns (uint)
{
return self.cll[n][d];
}
// Can be used before `insert` to build an ordered list
// `a` an existing node to search from, e.g. HEAD.
// `b` value to seek
// `r` first node beyond `b` in direction `d`
function seek(CLL storage self, uint a, uint b, bool d)
internal constant returns (uint r)
{
r = step(self, a, d);
while ((b!=r) && ((b < r) != d)) r = self.cll[r][d];
return;
}
// Creates a bidirectional link between two nodes on direction `d`
function stitch(CLL storage self, uint a, uint b, bool d) internal {
self.cll[b][!d] = a;
self.cll[a][d] = b;
}
// Insert node `b` beside existing node `a` in direction `d`.
function insert (CLL storage self, uint a, uint b, bool d) internal {
uint c = self.cll[a][d];
stitch (self, a, b, d);
stitch (self, b, c, d);
}
function remove(CLL storage self, uint n) internal returns (uint) {
if (n == NULL) return;
stitch(self, self.cll[n][PREV], self.cll[n][NEXT], NEXT);
delete self.cll[n][PREV];
delete self.cll[n][NEXT];
return n;
}
function push(CLL storage self, uint n, bool d) internal {
insert(self, HEAD, n, d);
}
function pop(CLL storage self, bool d) internal returns (uint) {
return remove(self, step(self, HEAD, d));
}
} | // LibCLL using `uint` keys | LineComment | stitch | function stitch(CLL storage self, uint a, uint b, bool d) internal {
self.cll[b][!d] = a;
self.cll[a][d] = b;
}
| // Creates a bidirectional link between two nodes on direction `d` | LineComment | v0.4.20+commit.3155dd80 | bzzr://373bce966b5a3a64cb5cee60e45ef2089d4f385eea83351e825cfda31d420536 | {
"func_code_index": [
1977,
2117
]
} | 9,187 |
|
AquaToken | AquaToken.sol | 0x1d97bccc6296aac6f0be796c7e8cb270eca4c6c6 | Solidity | LibCLLu | library LibCLLu {
string constant public VERSION = "LibCLLu 0.4.0";
uint constant NULL = 0;
uint constant HEAD = 0;
bool constant PREV = false;
bool constant NEXT = true;
struct CLL{
mapping (uint => mapping (bool => uint)) cll;
}
// n: node id d: direction r: return node id
// Return existential state of a node. n == HEAD returns list existence.
function exists(CLL storage self, uint n)
internal
constant returns (bool)
{
if (self.cll[n][PREV] != HEAD || self.cll[n][NEXT] != HEAD)
return true;
if (n == HEAD)
return false;
if (self.cll[HEAD][NEXT] == n)
return true;
return false;
}
// Returns the number of elements in the list
function sizeOf(CLL storage self) internal constant returns (uint r) {
uint i = step(self, HEAD, NEXT);
while (i != HEAD) {
i = step(self, i, NEXT);
r++;
}
return;
}
// Returns the links of a node as and array
function getNode(CLL storage self, uint n)
internal constant returns (uint[2])
{
return [self.cll[n][PREV], self.cll[n][NEXT]];
}
// Returns the link of a node `n` in direction `d`.
function step(CLL storage self, uint n, bool d)
internal constant returns (uint)
{
return self.cll[n][d];
}
// Can be used before `insert` to build an ordered list
// `a` an existing node to search from, e.g. HEAD.
// `b` value to seek
// `r` first node beyond `b` in direction `d`
function seek(CLL storage self, uint a, uint b, bool d)
internal constant returns (uint r)
{
r = step(self, a, d);
while ((b!=r) && ((b < r) != d)) r = self.cll[r][d];
return;
}
// Creates a bidirectional link between two nodes on direction `d`
function stitch(CLL storage self, uint a, uint b, bool d) internal {
self.cll[b][!d] = a;
self.cll[a][d] = b;
}
// Insert node `b` beside existing node `a` in direction `d`.
function insert (CLL storage self, uint a, uint b, bool d) internal {
uint c = self.cll[a][d];
stitch (self, a, b, d);
stitch (self, b, c, d);
}
function remove(CLL storage self, uint n) internal returns (uint) {
if (n == NULL) return;
stitch(self, self.cll[n][PREV], self.cll[n][NEXT], NEXT);
delete self.cll[n][PREV];
delete self.cll[n][NEXT];
return n;
}
function push(CLL storage self, uint n, bool d) internal {
insert(self, HEAD, n, d);
}
function pop(CLL storage self, bool d) internal returns (uint) {
return remove(self, step(self, HEAD, d));
}
} | // LibCLL using `uint` keys | LineComment | insert | function insert (CLL storage self, uint a, uint b, bool d) internal {
uint c = self.cll[a][d];
stitch (self, a, b, d);
stitch (self, b, c, d);
}
| // Insert node `b` beside existing node `a` in direction `d`. | LineComment | v0.4.20+commit.3155dd80 | bzzr://373bce966b5a3a64cb5cee60e45ef2089d4f385eea83351e825cfda31d420536 | {
"func_code_index": [
2187,
2369
]
} | 9,188 |
|
AquaToken | AquaToken.sol | 0x1d97bccc6296aac6f0be796c7e8cb270eca4c6c6 | Solidity | LibCLLi | library LibCLLi {
string constant public VERSION = "LibCLLi 0.4.0";
int constant NULL = 0;
int constant HEAD = 0;
bool constant PREV = false;
bool constant NEXT = true;
struct CLL{
mapping (int => mapping (bool => int)) cll;
}
// n: node id d: direction r: return node id
// Return existential state of a node. n == HEAD returns list existence.
function exists(CLL storage self, int n) internal constant returns (bool) {
if (self.cll[n][PREV] != HEAD || self.cll[n][NEXT] != HEAD)
return true;
if (n == HEAD)
return false;
if (self.cll[HEAD][NEXT] == n)
return true;
return false;
}
// Returns the number of elements in the list
function sizeOf(CLL storage self) internal constant returns (uint r) {
int i = step(self, HEAD, NEXT);
while (i != HEAD) {
i = step(self, i, NEXT);
r++;
}
return;
}
// Returns the links of a node as and array
function getNode(CLL storage self, int n)
internal constant returns (int[2])
{
return [self.cll[n][PREV], self.cll[n][NEXT]];
}
// Returns the link of a node `n` in direction `d`.
function step(CLL storage self, int n, bool d)
internal constant returns (int)
{
return self.cll[n][d];
}
// Can be used before `insert` to build an ordered list
// `a` an existing node to search from, e.g. HEAD.
// `b` value to seek
// `r` first node beyond `b` in direction `d`
function seek(CLL storage self, int a, int b, bool d)
internal constant returns (int r)
{
r = step(self, a, d);
while ((b!=r) && ((b < r) != d)) r = self.cll[r][d];
return;
}
// Creates a bidirectional link between two nodes on direction `d`
function stitch(CLL storage self, int a, int b, bool d) internal {
self.cll[b][!d] = a;
self.cll[a][d] = b;
}
// Insert node `b` beside existing node `a` in direction `d`.
function insert (CLL storage self, int a, int b, bool d) internal {
int c = self.cll[a][d];
stitch (self, a, b, d);
stitch (self, b, c, d);
}
function remove(CLL storage self, int n) internal returns (int) {
if (n == NULL) return;
stitch(self, self.cll[n][PREV], self.cll[n][NEXT], NEXT);
delete self.cll[n][PREV];
delete self.cll[n][NEXT];
return n;
}
function push(CLL storage self, int n, bool d) internal {
insert(self, HEAD, n, d);
}
function pop(CLL storage self, bool d) internal returns (int) {
return remove(self, step(self, HEAD, d));
}
} | // LibCLL using `int` keys | LineComment | exists | function exists(CLL storage self, int n) internal constant returns (bool) {
if (self.cll[n][PREV] != HEAD || self.cll[n][NEXT] != HEAD)
return true;
if (n == HEAD)
return false;
if (self.cll[HEAD][NEXT] == n)
return true;
return false;
}
| // n: node id d: direction r: return node id
// Return existential state of a node. n == HEAD returns list existence. | LineComment | v0.4.20+commit.3155dd80 | bzzr://373bce966b5a3a64cb5cee60e45ef2089d4f385eea83351e825cfda31d420536 | {
"func_code_index": [
414,
736
]
} | 9,189 |
|
AquaToken | AquaToken.sol | 0x1d97bccc6296aac6f0be796c7e8cb270eca4c6c6 | Solidity | LibCLLi | library LibCLLi {
string constant public VERSION = "LibCLLi 0.4.0";
int constant NULL = 0;
int constant HEAD = 0;
bool constant PREV = false;
bool constant NEXT = true;
struct CLL{
mapping (int => mapping (bool => int)) cll;
}
// n: node id d: direction r: return node id
// Return existential state of a node. n == HEAD returns list existence.
function exists(CLL storage self, int n) internal constant returns (bool) {
if (self.cll[n][PREV] != HEAD || self.cll[n][NEXT] != HEAD)
return true;
if (n == HEAD)
return false;
if (self.cll[HEAD][NEXT] == n)
return true;
return false;
}
// Returns the number of elements in the list
function sizeOf(CLL storage self) internal constant returns (uint r) {
int i = step(self, HEAD, NEXT);
while (i != HEAD) {
i = step(self, i, NEXT);
r++;
}
return;
}
// Returns the links of a node as and array
function getNode(CLL storage self, int n)
internal constant returns (int[2])
{
return [self.cll[n][PREV], self.cll[n][NEXT]];
}
// Returns the link of a node `n` in direction `d`.
function step(CLL storage self, int n, bool d)
internal constant returns (int)
{
return self.cll[n][d];
}
// Can be used before `insert` to build an ordered list
// `a` an existing node to search from, e.g. HEAD.
// `b` value to seek
// `r` first node beyond `b` in direction `d`
function seek(CLL storage self, int a, int b, bool d)
internal constant returns (int r)
{
r = step(self, a, d);
while ((b!=r) && ((b < r) != d)) r = self.cll[r][d];
return;
}
// Creates a bidirectional link between two nodes on direction `d`
function stitch(CLL storage self, int a, int b, bool d) internal {
self.cll[b][!d] = a;
self.cll[a][d] = b;
}
// Insert node `b` beside existing node `a` in direction `d`.
function insert (CLL storage self, int a, int b, bool d) internal {
int c = self.cll[a][d];
stitch (self, a, b, d);
stitch (self, b, c, d);
}
function remove(CLL storage self, int n) internal returns (int) {
if (n == NULL) return;
stitch(self, self.cll[n][PREV], self.cll[n][NEXT], NEXT);
delete self.cll[n][PREV];
delete self.cll[n][NEXT];
return n;
}
function push(CLL storage self, int n, bool d) internal {
insert(self, HEAD, n, d);
}
function pop(CLL storage self, bool d) internal returns (int) {
return remove(self, step(self, HEAD, d));
}
} | // LibCLL using `int` keys | LineComment | sizeOf | function sizeOf(CLL storage self) internal constant returns (uint r) {
int i = step(self, HEAD, NEXT);
while (i != HEAD) {
i = step(self, i, NEXT);
r++;
}
return;
}
| // Returns the number of elements in the list | LineComment | v0.4.20+commit.3155dd80 | bzzr://373bce966b5a3a64cb5cee60e45ef2089d4f385eea83351e825cfda31d420536 | {
"func_code_index": [
788,
1024
]
} | 9,190 |
|
AquaToken | AquaToken.sol | 0x1d97bccc6296aac6f0be796c7e8cb270eca4c6c6 | Solidity | LibCLLi | library LibCLLi {
string constant public VERSION = "LibCLLi 0.4.0";
int constant NULL = 0;
int constant HEAD = 0;
bool constant PREV = false;
bool constant NEXT = true;
struct CLL{
mapping (int => mapping (bool => int)) cll;
}
// n: node id d: direction r: return node id
// Return existential state of a node. n == HEAD returns list existence.
function exists(CLL storage self, int n) internal constant returns (bool) {
if (self.cll[n][PREV] != HEAD || self.cll[n][NEXT] != HEAD)
return true;
if (n == HEAD)
return false;
if (self.cll[HEAD][NEXT] == n)
return true;
return false;
}
// Returns the number of elements in the list
function sizeOf(CLL storage self) internal constant returns (uint r) {
int i = step(self, HEAD, NEXT);
while (i != HEAD) {
i = step(self, i, NEXT);
r++;
}
return;
}
// Returns the links of a node as and array
function getNode(CLL storage self, int n)
internal constant returns (int[2])
{
return [self.cll[n][PREV], self.cll[n][NEXT]];
}
// Returns the link of a node `n` in direction `d`.
function step(CLL storage self, int n, bool d)
internal constant returns (int)
{
return self.cll[n][d];
}
// Can be used before `insert` to build an ordered list
// `a` an existing node to search from, e.g. HEAD.
// `b` value to seek
// `r` first node beyond `b` in direction `d`
function seek(CLL storage self, int a, int b, bool d)
internal constant returns (int r)
{
r = step(self, a, d);
while ((b!=r) && ((b < r) != d)) r = self.cll[r][d];
return;
}
// Creates a bidirectional link between two nodes on direction `d`
function stitch(CLL storage self, int a, int b, bool d) internal {
self.cll[b][!d] = a;
self.cll[a][d] = b;
}
// Insert node `b` beside existing node `a` in direction `d`.
function insert (CLL storage self, int a, int b, bool d) internal {
int c = self.cll[a][d];
stitch (self, a, b, d);
stitch (self, b, c, d);
}
function remove(CLL storage self, int n) internal returns (int) {
if (n == NULL) return;
stitch(self, self.cll[n][PREV], self.cll[n][NEXT], NEXT);
delete self.cll[n][PREV];
delete self.cll[n][NEXT];
return n;
}
function push(CLL storage self, int n, bool d) internal {
insert(self, HEAD, n, d);
}
function pop(CLL storage self, bool d) internal returns (int) {
return remove(self, step(self, HEAD, d));
}
} | // LibCLL using `int` keys | LineComment | getNode | function getNode(CLL storage self, int n)
internal constant returns (int[2])
{
return [self.cll[n][PREV], self.cll[n][NEXT]];
}
| // Returns the links of a node as and array | LineComment | v0.4.20+commit.3155dd80 | bzzr://373bce966b5a3a64cb5cee60e45ef2089d4f385eea83351e825cfda31d420536 | {
"func_code_index": [
1076,
1237
]
} | 9,191 |
|
AquaToken | AquaToken.sol | 0x1d97bccc6296aac6f0be796c7e8cb270eca4c6c6 | Solidity | LibCLLi | library LibCLLi {
string constant public VERSION = "LibCLLi 0.4.0";
int constant NULL = 0;
int constant HEAD = 0;
bool constant PREV = false;
bool constant NEXT = true;
struct CLL{
mapping (int => mapping (bool => int)) cll;
}
// n: node id d: direction r: return node id
// Return existential state of a node. n == HEAD returns list existence.
function exists(CLL storage self, int n) internal constant returns (bool) {
if (self.cll[n][PREV] != HEAD || self.cll[n][NEXT] != HEAD)
return true;
if (n == HEAD)
return false;
if (self.cll[HEAD][NEXT] == n)
return true;
return false;
}
// Returns the number of elements in the list
function sizeOf(CLL storage self) internal constant returns (uint r) {
int i = step(self, HEAD, NEXT);
while (i != HEAD) {
i = step(self, i, NEXT);
r++;
}
return;
}
// Returns the links of a node as and array
function getNode(CLL storage self, int n)
internal constant returns (int[2])
{
return [self.cll[n][PREV], self.cll[n][NEXT]];
}
// Returns the link of a node `n` in direction `d`.
function step(CLL storage self, int n, bool d)
internal constant returns (int)
{
return self.cll[n][d];
}
// Can be used before `insert` to build an ordered list
// `a` an existing node to search from, e.g. HEAD.
// `b` value to seek
// `r` first node beyond `b` in direction `d`
function seek(CLL storage self, int a, int b, bool d)
internal constant returns (int r)
{
r = step(self, a, d);
while ((b!=r) && ((b < r) != d)) r = self.cll[r][d];
return;
}
// Creates a bidirectional link between two nodes on direction `d`
function stitch(CLL storage self, int a, int b, bool d) internal {
self.cll[b][!d] = a;
self.cll[a][d] = b;
}
// Insert node `b` beside existing node `a` in direction `d`.
function insert (CLL storage self, int a, int b, bool d) internal {
int c = self.cll[a][d];
stitch (self, a, b, d);
stitch (self, b, c, d);
}
function remove(CLL storage self, int n) internal returns (int) {
if (n == NULL) return;
stitch(self, self.cll[n][PREV], self.cll[n][NEXT], NEXT);
delete self.cll[n][PREV];
delete self.cll[n][NEXT];
return n;
}
function push(CLL storage self, int n, bool d) internal {
insert(self, HEAD, n, d);
}
function pop(CLL storage self, bool d) internal returns (int) {
return remove(self, step(self, HEAD, d));
}
} | // LibCLL using `int` keys | LineComment | step | function step(CLL storage self, int n, bool d)
internal constant returns (int)
{
return self.cll[n][d];
}
| // Returns the link of a node `n` in direction `d`. | LineComment | v0.4.20+commit.3155dd80 | bzzr://373bce966b5a3a64cb5cee60e45ef2089d4f385eea83351e825cfda31d420536 | {
"func_code_index": [
1297,
1436
]
} | 9,192 |
|
AquaToken | AquaToken.sol | 0x1d97bccc6296aac6f0be796c7e8cb270eca4c6c6 | Solidity | LibCLLi | library LibCLLi {
string constant public VERSION = "LibCLLi 0.4.0";
int constant NULL = 0;
int constant HEAD = 0;
bool constant PREV = false;
bool constant NEXT = true;
struct CLL{
mapping (int => mapping (bool => int)) cll;
}
// n: node id d: direction r: return node id
// Return existential state of a node. n == HEAD returns list existence.
function exists(CLL storage self, int n) internal constant returns (bool) {
if (self.cll[n][PREV] != HEAD || self.cll[n][NEXT] != HEAD)
return true;
if (n == HEAD)
return false;
if (self.cll[HEAD][NEXT] == n)
return true;
return false;
}
// Returns the number of elements in the list
function sizeOf(CLL storage self) internal constant returns (uint r) {
int i = step(self, HEAD, NEXT);
while (i != HEAD) {
i = step(self, i, NEXT);
r++;
}
return;
}
// Returns the links of a node as and array
function getNode(CLL storage self, int n)
internal constant returns (int[2])
{
return [self.cll[n][PREV], self.cll[n][NEXT]];
}
// Returns the link of a node `n` in direction `d`.
function step(CLL storage self, int n, bool d)
internal constant returns (int)
{
return self.cll[n][d];
}
// Can be used before `insert` to build an ordered list
// `a` an existing node to search from, e.g. HEAD.
// `b` value to seek
// `r` first node beyond `b` in direction `d`
function seek(CLL storage self, int a, int b, bool d)
internal constant returns (int r)
{
r = step(self, a, d);
while ((b!=r) && ((b < r) != d)) r = self.cll[r][d];
return;
}
// Creates a bidirectional link between two nodes on direction `d`
function stitch(CLL storage self, int a, int b, bool d) internal {
self.cll[b][!d] = a;
self.cll[a][d] = b;
}
// Insert node `b` beside existing node `a` in direction `d`.
function insert (CLL storage self, int a, int b, bool d) internal {
int c = self.cll[a][d];
stitch (self, a, b, d);
stitch (self, b, c, d);
}
function remove(CLL storage self, int n) internal returns (int) {
if (n == NULL) return;
stitch(self, self.cll[n][PREV], self.cll[n][NEXT], NEXT);
delete self.cll[n][PREV];
delete self.cll[n][NEXT];
return n;
}
function push(CLL storage self, int n, bool d) internal {
insert(self, HEAD, n, d);
}
function pop(CLL storage self, bool d) internal returns (int) {
return remove(self, step(self, HEAD, d));
}
} | // LibCLL using `int` keys | LineComment | seek | function seek(CLL storage self, int a, int b, bool d)
internal constant returns (int r)
{
r = step(self, a, d);
while ((b!=r) && ((b < r) != d)) r = self.cll[r][d];
return;
}
| // Can be used before `insert` to build an ordered list
// `a` an existing node to search from, e.g. HEAD.
// `b` value to seek
// `r` first node beyond `b` in direction `d` | LineComment | v0.4.20+commit.3155dd80 | bzzr://373bce966b5a3a64cb5cee60e45ef2089d4f385eea83351e825cfda31d420536 | {
"func_code_index": [
1633,
1860
]
} | 9,193 |
|
AquaToken | AquaToken.sol | 0x1d97bccc6296aac6f0be796c7e8cb270eca4c6c6 | Solidity | LibCLLi | library LibCLLi {
string constant public VERSION = "LibCLLi 0.4.0";
int constant NULL = 0;
int constant HEAD = 0;
bool constant PREV = false;
bool constant NEXT = true;
struct CLL{
mapping (int => mapping (bool => int)) cll;
}
// n: node id d: direction r: return node id
// Return existential state of a node. n == HEAD returns list existence.
function exists(CLL storage self, int n) internal constant returns (bool) {
if (self.cll[n][PREV] != HEAD || self.cll[n][NEXT] != HEAD)
return true;
if (n == HEAD)
return false;
if (self.cll[HEAD][NEXT] == n)
return true;
return false;
}
// Returns the number of elements in the list
function sizeOf(CLL storage self) internal constant returns (uint r) {
int i = step(self, HEAD, NEXT);
while (i != HEAD) {
i = step(self, i, NEXT);
r++;
}
return;
}
// Returns the links of a node as and array
function getNode(CLL storage self, int n)
internal constant returns (int[2])
{
return [self.cll[n][PREV], self.cll[n][NEXT]];
}
// Returns the link of a node `n` in direction `d`.
function step(CLL storage self, int n, bool d)
internal constant returns (int)
{
return self.cll[n][d];
}
// Can be used before `insert` to build an ordered list
// `a` an existing node to search from, e.g. HEAD.
// `b` value to seek
// `r` first node beyond `b` in direction `d`
function seek(CLL storage self, int a, int b, bool d)
internal constant returns (int r)
{
r = step(self, a, d);
while ((b!=r) && ((b < r) != d)) r = self.cll[r][d];
return;
}
// Creates a bidirectional link between two nodes on direction `d`
function stitch(CLL storage self, int a, int b, bool d) internal {
self.cll[b][!d] = a;
self.cll[a][d] = b;
}
// Insert node `b` beside existing node `a` in direction `d`.
function insert (CLL storage self, int a, int b, bool d) internal {
int c = self.cll[a][d];
stitch (self, a, b, d);
stitch (self, b, c, d);
}
function remove(CLL storage self, int n) internal returns (int) {
if (n == NULL) return;
stitch(self, self.cll[n][PREV], self.cll[n][NEXT], NEXT);
delete self.cll[n][PREV];
delete self.cll[n][NEXT];
return n;
}
function push(CLL storage self, int n, bool d) internal {
insert(self, HEAD, n, d);
}
function pop(CLL storage self, bool d) internal returns (int) {
return remove(self, step(self, HEAD, d));
}
} | // LibCLL using `int` keys | LineComment | stitch | function stitch(CLL storage self, int a, int b, bool d) internal {
self.cll[b][!d] = a;
self.cll[a][d] = b;
}
| // Creates a bidirectional link between two nodes on direction `d` | LineComment | v0.4.20+commit.3155dd80 | bzzr://373bce966b5a3a64cb5cee60e45ef2089d4f385eea83351e825cfda31d420536 | {
"func_code_index": [
1935,
2073
]
} | 9,194 |
|
AquaToken | AquaToken.sol | 0x1d97bccc6296aac6f0be796c7e8cb270eca4c6c6 | Solidity | LibCLLi | library LibCLLi {
string constant public VERSION = "LibCLLi 0.4.0";
int constant NULL = 0;
int constant HEAD = 0;
bool constant PREV = false;
bool constant NEXT = true;
struct CLL{
mapping (int => mapping (bool => int)) cll;
}
// n: node id d: direction r: return node id
// Return existential state of a node. n == HEAD returns list existence.
function exists(CLL storage self, int n) internal constant returns (bool) {
if (self.cll[n][PREV] != HEAD || self.cll[n][NEXT] != HEAD)
return true;
if (n == HEAD)
return false;
if (self.cll[HEAD][NEXT] == n)
return true;
return false;
}
// Returns the number of elements in the list
function sizeOf(CLL storage self) internal constant returns (uint r) {
int i = step(self, HEAD, NEXT);
while (i != HEAD) {
i = step(self, i, NEXT);
r++;
}
return;
}
// Returns the links of a node as and array
function getNode(CLL storage self, int n)
internal constant returns (int[2])
{
return [self.cll[n][PREV], self.cll[n][NEXT]];
}
// Returns the link of a node `n` in direction `d`.
function step(CLL storage self, int n, bool d)
internal constant returns (int)
{
return self.cll[n][d];
}
// Can be used before `insert` to build an ordered list
// `a` an existing node to search from, e.g. HEAD.
// `b` value to seek
// `r` first node beyond `b` in direction `d`
function seek(CLL storage self, int a, int b, bool d)
internal constant returns (int r)
{
r = step(self, a, d);
while ((b!=r) && ((b < r) != d)) r = self.cll[r][d];
return;
}
// Creates a bidirectional link between two nodes on direction `d`
function stitch(CLL storage self, int a, int b, bool d) internal {
self.cll[b][!d] = a;
self.cll[a][d] = b;
}
// Insert node `b` beside existing node `a` in direction `d`.
function insert (CLL storage self, int a, int b, bool d) internal {
int c = self.cll[a][d];
stitch (self, a, b, d);
stitch (self, b, c, d);
}
function remove(CLL storage self, int n) internal returns (int) {
if (n == NULL) return;
stitch(self, self.cll[n][PREV], self.cll[n][NEXT], NEXT);
delete self.cll[n][PREV];
delete self.cll[n][NEXT];
return n;
}
function push(CLL storage self, int n, bool d) internal {
insert(self, HEAD, n, d);
}
function pop(CLL storage self, bool d) internal returns (int) {
return remove(self, step(self, HEAD, d));
}
} | // LibCLL using `int` keys | LineComment | insert | function insert (CLL storage self, int a, int b, bool d) internal {
int c = self.cll[a][d];
stitch (self, a, b, d);
stitch (self, b, c, d);
}
| // Insert node `b` beside existing node `a` in direction `d`. | LineComment | v0.4.20+commit.3155dd80 | bzzr://373bce966b5a3a64cb5cee60e45ef2089d4f385eea83351e825cfda31d420536 | {
"func_code_index": [
2143,
2322
]
} | 9,195 |
|
AquaToken | AquaToken.sol | 0x1d97bccc6296aac6f0be796c7e8cb270eca4c6c6 | Solidity | LibCLLa | library LibCLLa {
string constant public VERSION = "LibCLLa 0.4.0";
address constant NULL = 0;
address constant HEAD = 0;
bool constant PREV = false;
bool constant NEXT = true;
struct CLL{
mapping (address => mapping (bool => address)) cll;
}
// n: node id d: direction r: return node id
// Return existential state of a node. n == HEAD returns list existence.
function exists(CLL storage self, address n) internal constant returns (bool) {
if (self.cll[n][PREV] != HEAD || self.cll[n][NEXT] != HEAD)
return true;
if (n == HEAD)
return false;
if (self.cll[HEAD][NEXT] == n)
return true;
return false;
}
// Returns the number of elements in the list
function sizeOf(CLL storage self) internal constant returns (uint r) {
address i = step(self, HEAD, NEXT);
while (i != HEAD) {
i = step(self, i, NEXT);
r++;
}
return;
}
// Returns the links of a node as and array
function getNode(CLL storage self, address n)
internal constant returns (address[2])
{
return [self.cll[n][PREV], self.cll[n][NEXT]];
}
// Returns the link of a node `n` in direction `d`.
function step(CLL storage self, address n, bool d)
internal constant returns (address)
{
return self.cll[n][d];
}
// Can be used before `insert` to build an ordered list
// `a` an existing node to search from, e.g. HEAD.
// `b` value to seek
// `r` first node beyond `b` in direction `d`
function seek(CLL storage self, address a, address b, bool d)
internal constant returns (address r)
{
r = step(self, a, d);
while ((b!=r) && ((b < r) != d)) r = self.cll[r][d];
return;
}
// Creates a bidirectional link between two nodes on direction `d`
function stitch(CLL storage self, address a, address b, bool d) internal {
self.cll[b][!d] = a;
self.cll[a][d] = b;
}
// Insert node `b` beside existing node `a` in direction `d`.
function insert (CLL storage self, address a, address b, bool d) internal {
address c = self.cll[a][d];
stitch (self, a, b, d);
stitch (self, b, c, d);
}
function remove(CLL storage self, address n) internal returns (address) {
if (n == NULL) return;
stitch(self, self.cll[n][PREV], self.cll[n][NEXT], NEXT);
delete self.cll[n][PREV];
delete self.cll[n][NEXT];
return n;
}
function push(CLL storage self, address n, bool d) internal {
insert(self, HEAD, n, d);
}
function pop(CLL storage self, bool d) internal returns (address) {
return remove(self, step(self, HEAD, d));
}
} | // LibCLL using `address` keys | LineComment | exists | function exists(CLL storage self, address n) internal constant returns (bool) {
if (self.cll[n][PREV] != HEAD || self.cll[n][NEXT] != HEAD)
return true;
if (n == HEAD)
return false;
if (self.cll[HEAD][NEXT] == n)
return true;
return false;
}
| // n: node id d: direction r: return node id
// Return existential state of a node. n == HEAD returns list existence. | LineComment | v0.4.20+commit.3155dd80 | bzzr://373bce966b5a3a64cb5cee60e45ef2089d4f385eea83351e825cfda31d420536 | {
"func_code_index": [
430,
756
]
} | 9,196 |
|
AquaToken | AquaToken.sol | 0x1d97bccc6296aac6f0be796c7e8cb270eca4c6c6 | Solidity | LibCLLa | library LibCLLa {
string constant public VERSION = "LibCLLa 0.4.0";
address constant NULL = 0;
address constant HEAD = 0;
bool constant PREV = false;
bool constant NEXT = true;
struct CLL{
mapping (address => mapping (bool => address)) cll;
}
// n: node id d: direction r: return node id
// Return existential state of a node. n == HEAD returns list existence.
function exists(CLL storage self, address n) internal constant returns (bool) {
if (self.cll[n][PREV] != HEAD || self.cll[n][NEXT] != HEAD)
return true;
if (n == HEAD)
return false;
if (self.cll[HEAD][NEXT] == n)
return true;
return false;
}
// Returns the number of elements in the list
function sizeOf(CLL storage self) internal constant returns (uint r) {
address i = step(self, HEAD, NEXT);
while (i != HEAD) {
i = step(self, i, NEXT);
r++;
}
return;
}
// Returns the links of a node as and array
function getNode(CLL storage self, address n)
internal constant returns (address[2])
{
return [self.cll[n][PREV], self.cll[n][NEXT]];
}
// Returns the link of a node `n` in direction `d`.
function step(CLL storage self, address n, bool d)
internal constant returns (address)
{
return self.cll[n][d];
}
// Can be used before `insert` to build an ordered list
// `a` an existing node to search from, e.g. HEAD.
// `b` value to seek
// `r` first node beyond `b` in direction `d`
function seek(CLL storage self, address a, address b, bool d)
internal constant returns (address r)
{
r = step(self, a, d);
while ((b!=r) && ((b < r) != d)) r = self.cll[r][d];
return;
}
// Creates a bidirectional link between two nodes on direction `d`
function stitch(CLL storage self, address a, address b, bool d) internal {
self.cll[b][!d] = a;
self.cll[a][d] = b;
}
// Insert node `b` beside existing node `a` in direction `d`.
function insert (CLL storage self, address a, address b, bool d) internal {
address c = self.cll[a][d];
stitch (self, a, b, d);
stitch (self, b, c, d);
}
function remove(CLL storage self, address n) internal returns (address) {
if (n == NULL) return;
stitch(self, self.cll[n][PREV], self.cll[n][NEXT], NEXT);
delete self.cll[n][PREV];
delete self.cll[n][NEXT];
return n;
}
function push(CLL storage self, address n, bool d) internal {
insert(self, HEAD, n, d);
}
function pop(CLL storage self, bool d) internal returns (address) {
return remove(self, step(self, HEAD, d));
}
} | // LibCLL using `address` keys | LineComment | sizeOf | function sizeOf(CLL storage self) internal constant returns (uint r) {
address i = step(self, HEAD, NEXT);
while (i != HEAD) {
i = step(self, i, NEXT);
r++;
}
return;
}
| // Returns the number of elements in the list | LineComment | v0.4.20+commit.3155dd80 | bzzr://373bce966b5a3a64cb5cee60e45ef2089d4f385eea83351e825cfda31d420536 | {
"func_code_index": [
808,
1048
]
} | 9,197 |
|
AquaToken | AquaToken.sol | 0x1d97bccc6296aac6f0be796c7e8cb270eca4c6c6 | Solidity | LibCLLa | library LibCLLa {
string constant public VERSION = "LibCLLa 0.4.0";
address constant NULL = 0;
address constant HEAD = 0;
bool constant PREV = false;
bool constant NEXT = true;
struct CLL{
mapping (address => mapping (bool => address)) cll;
}
// n: node id d: direction r: return node id
// Return existential state of a node. n == HEAD returns list existence.
function exists(CLL storage self, address n) internal constant returns (bool) {
if (self.cll[n][PREV] != HEAD || self.cll[n][NEXT] != HEAD)
return true;
if (n == HEAD)
return false;
if (self.cll[HEAD][NEXT] == n)
return true;
return false;
}
// Returns the number of elements in the list
function sizeOf(CLL storage self) internal constant returns (uint r) {
address i = step(self, HEAD, NEXT);
while (i != HEAD) {
i = step(self, i, NEXT);
r++;
}
return;
}
// Returns the links of a node as and array
function getNode(CLL storage self, address n)
internal constant returns (address[2])
{
return [self.cll[n][PREV], self.cll[n][NEXT]];
}
// Returns the link of a node `n` in direction `d`.
function step(CLL storage self, address n, bool d)
internal constant returns (address)
{
return self.cll[n][d];
}
// Can be used before `insert` to build an ordered list
// `a` an existing node to search from, e.g. HEAD.
// `b` value to seek
// `r` first node beyond `b` in direction `d`
function seek(CLL storage self, address a, address b, bool d)
internal constant returns (address r)
{
r = step(self, a, d);
while ((b!=r) && ((b < r) != d)) r = self.cll[r][d];
return;
}
// Creates a bidirectional link between two nodes on direction `d`
function stitch(CLL storage self, address a, address b, bool d) internal {
self.cll[b][!d] = a;
self.cll[a][d] = b;
}
// Insert node `b` beside existing node `a` in direction `d`.
function insert (CLL storage self, address a, address b, bool d) internal {
address c = self.cll[a][d];
stitch (self, a, b, d);
stitch (self, b, c, d);
}
function remove(CLL storage self, address n) internal returns (address) {
if (n == NULL) return;
stitch(self, self.cll[n][PREV], self.cll[n][NEXT], NEXT);
delete self.cll[n][PREV];
delete self.cll[n][NEXT];
return n;
}
function push(CLL storage self, address n, bool d) internal {
insert(self, HEAD, n, d);
}
function pop(CLL storage self, bool d) internal returns (address) {
return remove(self, step(self, HEAD, d));
}
} | // LibCLL using `address` keys | LineComment | getNode | function getNode(CLL storage self, address n)
internal constant returns (address[2])
{
return [self.cll[n][PREV], self.cll[n][NEXT]];
}
| // Returns the links of a node as and array | LineComment | v0.4.20+commit.3155dd80 | bzzr://373bce966b5a3a64cb5cee60e45ef2089d4f385eea83351e825cfda31d420536 | {
"func_code_index": [
1100,
1269
]
} | 9,198 |
|
AquaToken | AquaToken.sol | 0x1d97bccc6296aac6f0be796c7e8cb270eca4c6c6 | Solidity | LibCLLa | library LibCLLa {
string constant public VERSION = "LibCLLa 0.4.0";
address constant NULL = 0;
address constant HEAD = 0;
bool constant PREV = false;
bool constant NEXT = true;
struct CLL{
mapping (address => mapping (bool => address)) cll;
}
// n: node id d: direction r: return node id
// Return existential state of a node. n == HEAD returns list existence.
function exists(CLL storage self, address n) internal constant returns (bool) {
if (self.cll[n][PREV] != HEAD || self.cll[n][NEXT] != HEAD)
return true;
if (n == HEAD)
return false;
if (self.cll[HEAD][NEXT] == n)
return true;
return false;
}
// Returns the number of elements in the list
function sizeOf(CLL storage self) internal constant returns (uint r) {
address i = step(self, HEAD, NEXT);
while (i != HEAD) {
i = step(self, i, NEXT);
r++;
}
return;
}
// Returns the links of a node as and array
function getNode(CLL storage self, address n)
internal constant returns (address[2])
{
return [self.cll[n][PREV], self.cll[n][NEXT]];
}
// Returns the link of a node `n` in direction `d`.
function step(CLL storage self, address n, bool d)
internal constant returns (address)
{
return self.cll[n][d];
}
// Can be used before `insert` to build an ordered list
// `a` an existing node to search from, e.g. HEAD.
// `b` value to seek
// `r` first node beyond `b` in direction `d`
function seek(CLL storage self, address a, address b, bool d)
internal constant returns (address r)
{
r = step(self, a, d);
while ((b!=r) && ((b < r) != d)) r = self.cll[r][d];
return;
}
// Creates a bidirectional link between two nodes on direction `d`
function stitch(CLL storage self, address a, address b, bool d) internal {
self.cll[b][!d] = a;
self.cll[a][d] = b;
}
// Insert node `b` beside existing node `a` in direction `d`.
function insert (CLL storage self, address a, address b, bool d) internal {
address c = self.cll[a][d];
stitch (self, a, b, d);
stitch (self, b, c, d);
}
function remove(CLL storage self, address n) internal returns (address) {
if (n == NULL) return;
stitch(self, self.cll[n][PREV], self.cll[n][NEXT], NEXT);
delete self.cll[n][PREV];
delete self.cll[n][NEXT];
return n;
}
function push(CLL storage self, address n, bool d) internal {
insert(self, HEAD, n, d);
}
function pop(CLL storage self, bool d) internal returns (address) {
return remove(self, step(self, HEAD, d));
}
} | // LibCLL using `address` keys | LineComment | step | function step(CLL storage self, address n, bool d)
internal constant returns (address)
{
return self.cll[n][d];
}
| // Returns the link of a node `n` in direction `d`. | LineComment | v0.4.20+commit.3155dd80 | bzzr://373bce966b5a3a64cb5cee60e45ef2089d4f385eea83351e825cfda31d420536 | {
"func_code_index": [
1329,
1476
]
} | 9,199 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.