Source Code (Proxy)
Overview
ETH Balance
0 ETH
More Info
ContractCreator
Multichain Info
N/A
Loading...
Loading
Contract Name:
TokenManagerProxy
Compiler Version
v0.8.18+commit.87f61d96
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
/*
Copyright 2023 Wanchain Foundation.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// _ _ _
// __ ____ _ _ __ ___| |__ __ _(_)_ __ __| | _____ __
// \ \ /\ / / _` | '_ \ / __| '_ \ / _` | | '_ \@/ _` |/ _ \ \ / /
// \ V V / (_| | | | | (__| | | | (_| | | | | | (_| | __/\ V /
// \_/\_/ \__,_|_| |_|\___|_| |_|\__,_|_|_| |_|\__,_|\___| \_/
//
//
pragma solidity 0.8.18;
/**
* Math operations with safety checks
*/
import "../components/Admin.sol";
import "./TokenManagerStorage.sol";
import "../components/Proxy.sol";
/**
* @title TokenManagerProxy
* @dev Proxy contract for token management functionality
* This contract provides:
* - Upgradeable implementation for token management
* - Storage and admin functionality inheritance
* - Implementation upgrade mechanism
*/
contract TokenManagerProxy is TokenManagerStorage, Admin, Proxy {
/**
*
* MANIPULATIONS
*
*/
/**
* @notice Upgrades the implementation address of the TokenManagerDelegate contract
* @dev Can only be called by the contract owner
* @param impl Address of the new TokenManagerDelegate implementation
* Requirements:
* - Implementation address cannot be zero
* - Implementation address cannot be the same as current
* Emits:
* - Upgraded event with the new implementation address
*/
function upgradeTo(address impl) public onlyOwner {
require(impl != address(0), "Cannot upgrade to invalid address");
require(impl != _implementation, "Cannot upgrade to the same implementation");
_implementation = impl;
emit Upgraded(impl);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
import "./Owned.sol";
/**
* @title Admin
* @dev Contract for managing administrative access control
* This contract provides functionality for managing admin addresses
* and controlling access to administrative functions
*
* Key features:
* - Admin address management
* - Access control through modifiers
* - Admin addition and removal
*
* @custom:security
* - Inherits Owned contract for ownership management
* - Only owner can add/remove admins
* - Only admins can access protected functions
*/
contract Admin is Owned {
/**
* @dev Mapping of addresses to their admin status
*
* @custom:usage
* - Used to track admin addresses
* - Provides quick lookup for admin status
* - Supports admin access control
*/
mapping(address => bool) public mapAdmin;
/**
* @dev Emitted when a new admin is added
*
* @param admin The address of the newly added admin
*/
event AddAdmin(address admin);
/**
* @dev Emitted when an admin is removed
*
* @param admin The address of the removed admin
*/
event RemoveAdmin(address admin);
/**
* @dev Modifier to restrict function access to admin addresses only
*
* @custom:requirements
* - Caller must be an admin
*
* @custom:reverts
* - If caller is not an admin
*/
modifier onlyAdmin() {
require(mapAdmin[msg.sender], "not admin");
_;
}
/**
* @dev Adds a new admin address
*
* @param admin The address to be added as admin
*
* @custom:requirements
* - Caller must be the contract owner
*
* @custom:effects
* - Sets admin status for the address
* - Emits AddAdmin event
*/
function addAdmin(
address admin
)
external
onlyOwner
{
mapAdmin[admin] = true;
emit AddAdmin(admin);
}
/**
* @dev Removes an admin address
*
* @param admin The address to be removed from admin status
*
* @custom:requirements
* - Caller must be the contract owner
*
* @custom:effects
* - Removes admin status for the address
* - Emits RemoveAdmin event
*/
function removeAdmin(
address admin
)
external
onlyOwner
{
delete mapAdmin[admin];
emit RemoveAdmin(admin);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
import "../lib/BasicStorageLib.sol";
/**
* @title BasicStorage
* @dev Base contract for managing different types of storage data
* This contract provides basic storage functionality for various data types
* using the BasicStorageLib library
*
* Key features:
* - Multiple data type storage support
* - Library-based storage management
* - Internal storage access
*
* @custom:usage
* - Used as base contract for storage functionality
* - Provides structured storage for different data types
* - Supports inheritance for storage management
*/
contract BasicStorage {
/************************************************************
**
** VARIABLES
**
************************************************************/
//// basic variables
/**
* @dev Library usage declarations for different data types
*
* @custom:usage
* - UintData: For unsigned integer storage
* - BoolData: For boolean storage
* - AddressData: For address storage
* - BytesData: For bytes storage
* - StringData: For string storage
*/
using BasicStorageLib for BasicStorageLib.UintData;
using BasicStorageLib for BasicStorageLib.BoolData;
using BasicStorageLib for BasicStorageLib.AddressData;
using BasicStorageLib for BasicStorageLib.BytesData;
using BasicStorageLib for BasicStorageLib.StringData;
/**
* @dev Internal storage variables for different data types
*
* @custom:usage
* - uintData: Stores unsigned integers
* - boolData: Stores boolean values
* - addressData: Stores addresses
* - bytesData: Stores bytes data
* - stringData: Stores strings
*
* @custom:security
* - Internal visibility for controlled access
* - Library-based storage management
*/
BasicStorageLib.UintData internal uintData;
BasicStorageLib.BoolData internal boolData;
BasicStorageLib.AddressData internal addressData;
BasicStorageLib.BytesData internal bytesData;
BasicStorageLib.StringData internal stringData;
}// SPDX-License-Identifier: MIT
/*
Copyright 2023 Wanchain Foundation.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// _ _ _
// __ ____ _ _ __ ___| |__ __ _(_)_ __ __| | _____ __
// \ \ /\ / / _` | '_ \ / __| '_ \ / _` | | '_ \@/ _` |/ _ \ \ / /
// \ V V / (_| | | | | (__| | | | (_| | | | | | (_| | __/\ V /
// \_/\_/ \__,_|_| |_|\___|_| |_|\__,_|_|_| |_|\__,_|\___| \_/
//
//
pragma solidity ^0.8.18;
/**
* @title Owned
* @dev Base contract for ownership management
* This contract provides functionality for managing contract ownership
* with support for ownership transfer and renunciation
*
* Key features:
* - Ownership assignment
* - Ownership transfer
* - Ownership renunciation
* - Two-step ownership transfer
*
* @custom:security
* - Owner-only access control
* - Safe ownership transfer
* - Ownership renunciation capability
*/
contract Owned {
/**
* @dev Emitted when ownership is transferred
*
* @param previousOwner Address of the previous owner
* @param newOwner Address of the new owner
*/
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Modifier to restrict function access to owner only
*
* @custom:requirements
* - Caller must be the contract owner
*
* @custom:reverts
* - If caller is not the owner
*/
modifier onlyOwner() {
require(msg.sender == owner, "Not owner");
_;
}
/**
* @dev Public state variable for contract owner
*
* @custom:usage
* - Stores current owner address
* - Accessible for external queries
* - Modified through ownership functions
*/
address public owner;
/**
* @dev Constructor assigns initial owner
*
* @custom:effects
* - Sets initial owner to contract deployer
*/
constructor() {
owner = msg.sender;
}
/**
* @dev Public state variable for pending owner
*
* @custom:usage
* - Stores address of pending owner
* - Used in two-step ownership transfer
*/
address public newOwner;
/**
* @dev Transfers ownership to a new address
*
* @param _newOwner Address of the new owner
*
* @custom:requirements
* - Caller must be the current owner
* - New owner address must not be zero
*
* @custom:effects
* - Updates owner address
* - Emits OwnershipTransferred event
*/
function transferOwner(address _newOwner) public onlyOwner {
require(_newOwner != address(0), "New owner is the zero address");
emit OwnershipTransferred(owner, _newOwner);
owner = _newOwner;
}
/**
* @dev Initiates two-step ownership transfer
*
* @param _newOwner Address of the new owner
*
* @custom:requirements
* - Caller must be the current owner
*
* @custom:effects
* - Sets pending owner address
*/
function changeOwner(address _newOwner) public onlyOwner {
newOwner = _newOwner;
}
/**
* @dev Accepts pending ownership transfer
*
* @custom:requirements
* - Caller must be the pending owner
*
* @custom:effects
* - Updates owner address to pending owner
*/
function acceptOwnership() public {
if (msg.sender == newOwner) {
owner = newOwner;
}
}
/**
* @dev Renounces ownership of the contract
*
* @custom:requirements
* - Caller must be the current owner
*
* @custom:effects
* - Sets owner to zero address
* - Makes contract unowned
*/
function renounceOwnership() public onlyOwner {
owner = address(0);
}
}// SPDX-License-Identifier: MIT
/*
Copyright 2023 Wanchain Foundation.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// _ _ _
// __ ____ _ _ __ ___| |__ __ _(_)_ __ __| | _____ __
// \ \ /\ / / _` | '_ \ / __| '_ \ / _` | | '_ \@/ _` |/ _ \ \ / /
// \ V V / (_| | | | | (__| | | | (_| | | | | | (_| | __/\ V /
// \_/\_/ \__,_|_| |_|\___|_| |_|\__,_|_|_| |_|\__,_|\___| \_/
//
//
pragma solidity ^0.8.18;
/**
* @title Proxy
* @dev Base contract for proxy pattern implementation
* This contract provides functionality for delegating calls to implementation contracts
* and supports contract upgradeability
*
* Key features:
* - Implementation contract delegation
* - Contract upgrade support
* - Fallback handling
* - Receive function support
*
* @custom:security
* - Implementation address validation
* - Safe delegatecall execution
* - Proper return data handling
*/
contract Proxy {
/**
* @dev Emitted when the implementation contract is upgraded
*
* @param implementation Address of the new implementation contract
*/
event Upgraded(address indexed implementation);
/**
* @dev Internal storage for implementation contract address
*
* @custom:usage
* - Stores current implementation address
* - Used for delegatecall operations
* - Modified through upgrade operations
*/
address internal _implementation;
/**
* @dev Returns the current implementation contract address
*
* @return Address of the current implementation contract
*/
function implementation() public view returns (address) {
return _implementation;
}
/**
* @dev Internal function to handle fallback calls
* Delegates all calls to the implementation contract
*
* @custom:requirements
* - Implementation contract must be set
*
* @custom:effects
* - Executes delegatecall to implementation
* - Handles return data
*
* @custom:reverts
* - If implementation contract is not set
* - If delegatecall fails
*/
function _fallback() internal {
address _impl = _implementation;
require(_impl != address(0), "implementation contract not set");
assembly {
let ptr := mload(0x40)
calldatacopy(ptr, 0, calldatasize())
let result := delegatecall(gas(), _impl, ptr, calldatasize(), 0, 0)
let size := returndatasize()
returndatacopy(ptr, 0, size)
switch result
case 0 { revert(ptr, size) }
default { return(ptr, size) }
}
}
/**
* @dev Fallback function to handle unknown function calls
* Delegates all calls to the implementation contract
*
* @custom:effects
* - Forwards call to _fallback
*/
fallback() external payable {
return _fallback();
}
/**
* @dev Receive function to handle incoming ETH
* Delegates all calls to the implementation contract
*
* @custom:effects
* - Forwards call to _fallback
*/
receive() external payable {
return _fallback();
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
/**
* @title BasicStorageLib
* @dev Library for basic storage operations with support for multiple data types
* This library provides a structured approach to contract storage with a two-level key system
*
* Key features:
* - Support for multiple data types (uint, bool, address, bytes, string)
* - Two-level key storage system for flexible data organization
* - CRUD operations for each data type with consistent interface
* - Gas-efficient storage patterns
*
* @custom:security
* - Internal access only to prevent unauthorized storage manipulation
* - Safe storage operations with proper type enforcement
* - Type-specific operations to prevent type confusion
* - Consistent interface reduces likelihood of implementation errors
*
* @custom:usage
* - Used as a foundation for complex contract storage patterns
* - Enables modular and organized data storage in contracts
* - Simplifies storage access with standardized methods
* - Perfect for contracts with diverse data storage needs
*/
library BasicStorageLib {
/**
* @dev Structure for storing uint values
* Provides a two-level nested mapping for uint storage
*
* @custom:usage
* - Stores uint values with two-level key system for hierarchical data
* - Used for numeric data storage such as balances, timestamps, amounts
* - Primary key often represents a category, while innerKey represents specific item
* - Essential for tracking numeric values in complex systems
*/
struct UintData {
mapping(bytes => mapping(bytes => uint)) _storage;
}
/**
* @dev Structure for storing boolean values
* Provides a two-level nested mapping for boolean storage
*
* @custom:usage
* - Stores boolean values with two-level key system for hierarchical data
* - Used for flag and state storage such as activation status or permissions
* - Efficient for representing binary states (true/false)
* - Perfect for access control and feature toggles
*/
struct BoolData {
mapping(bytes => mapping(bytes => bool)) _storage;
}
/**
* @dev Structure for storing address values
* Provides a two-level nested mapping for address storage
*
* @custom:usage
* - Stores address values with two-level key system for hierarchical data
* - Used for contract and account address storage
* - Essential for tracking ownership, relationships between entities
* - Enables role-based systems and contract registries
*/
struct AddressData {
mapping(bytes => mapping(bytes => address)) _storage;
}
/**
* @dev Structure for storing bytes values
* Provides a two-level nested mapping for bytes storage
*
* @custom:usage
* - Stores bytes values with two-level key system for hierarchical data
* - Used for raw data storage such as cryptographic proofs, signatures
* - Perfect for storing variable-length binary data
* - Enables storage of complex serialized structures
*/
struct BytesData {
mapping(bytes => mapping(bytes => bytes)) _storage;
}
/**
* @dev Structure for storing string values
* Provides a two-level nested mapping for string storage
*
* @custom:usage
* - Stores string values with two-level key system for hierarchical data
* - Used for text data storage such as names, descriptions, metadata
* - Human-readable information storage
* - Suitable for configuration parameters and user-facing content
*/
struct StringData {
mapping(bytes => mapping(bytes => string)) _storage;
}
/**
* @dev Set uint value in storage
* Assigns a uint value to a specific key pair in storage
*
* @param self Storage structure reference
* @param key Primary key for categorization (e.g., user ID, token type)
* @param innerKey Secondary key for specific attribute (e.g., balance, timestamp)
* @param value Unsigned integer value to store
*
* @custom:effects
* - Updates storage with new value, overwriting any existing value
* - Gas usage scales with key sizes, not with value size
* - Optimized for single-slot storage operations
*/
function setStorage(UintData storage self, bytes memory key, bytes memory innerKey, uint value) internal {
self._storage[key][innerKey] = value;
}
/**
* @dev Get uint value from storage
* Retrieves a uint value from a specific key pair in storage
*
* @param self Storage structure reference
* @param key Primary key for categorization
* @param innerKey Secondary key for specific attribute
* @return Stored uint value, or 0 if no value has been set
*
* @custom:effects
* - Read-only operation that doesn't modify state
* - Returns default value (0) if entry doesn't exist
* - Gas cost is constant regardless of value stored
*/
function getStorage(UintData storage self, bytes memory key, bytes memory innerKey) internal view returns (uint) {
return self._storage[key][innerKey];
}
/**
* @dev Delete uint value from storage
* Removes a uint value from a specific key pair in storage
*
* @param self Storage structure reference
* @param key Primary key for categorization
* @param innerKey Secondary key for specific attribute
*
* @custom:effects
* - Removes value from storage, setting it to default value (0)
* - Gas refund is provided when clearing storage to zero
* - Frees up storage space, potentially reducing contract storage costs
*/
function delStorage(UintData storage self, bytes memory key, bytes memory innerKey) internal {
delete self._storage[key][innerKey];
}
/**
* @dev Set boolean value in storage
* Assigns a boolean value to a specific key pair in storage
*
* @param self Storage structure reference
* @param key Primary key for categorization (e.g., feature name, user ID)
* @param innerKey Secondary key for specific flag (e.g., active, approved)
* @param value Boolean value to store
*
* @custom:effects
* - Updates storage with new value, overwriting any existing value
* - Gas efficient for storing binary state information
* - Packs values efficiently in storage
*/
function setStorage(BoolData storage self, bytes memory key, bytes memory innerKey, bool value) internal {
self._storage[key][innerKey] = value;
}
/**
* @dev Get boolean value from storage
* Retrieves a boolean value from a specific key pair in storage
*
* @param self Storage structure reference
* @param key Primary key for categorization
* @param innerKey Secondary key for specific flag
* @return Stored boolean value, or false if no value has been set
*
* @custom:effects
* - Read-only operation that doesn't modify state
* - Returns default value (false) if entry doesn't exist
* - Gas efficient for checking state conditions
*/
function getStorage(BoolData storage self, bytes memory key, bytes memory innerKey) internal view returns (bool) {
return self._storage[key][innerKey];
}
/**
* @dev Delete boolean value from storage
* Removes a boolean value from a specific key pair in storage
*
* @param self Storage structure reference
* @param key Primary key for categorization
* @param innerKey Secondary key for specific flag
*
* @custom:effects
* - Removes value from storage, setting it to default value (false)
* - Gas refund is provided when clearing storage to zero
* - Particularly efficient for boolean values
*/
function delStorage(BoolData storage self, bytes memory key, bytes memory innerKey) internal {
delete self._storage[key][innerKey];
}
/**
* @dev Set address value in storage
* Assigns an address value to a specific key pair in storage
*
* @param self Storage structure reference
* @param key Primary key for categorization (e.g., role name, contract type)
* @param innerKey Secondary key for specific relationship (e.g., owner, delegate)
* @param value Ethereum address to store
*
* @custom:effects
* - Updates storage with new address, overwriting any existing value
* - Stores full 20-byte Ethereum addresses
* - Critical for tracking contract relationships and ownership
*/
function setStorage(AddressData storage self, bytes memory key, bytes memory innerKey, address value) internal {
self._storage[key][innerKey] = value;
}
/**
* @dev Get address value from storage
* Retrieves an address value from a specific key pair in storage
*
* @param self Storage structure reference
* @param key Primary key for categorization
* @param innerKey Secondary key for specific relationship
* @return Stored address value, or address(0) if no value has been set
*
* @custom:effects
* - Read-only operation that doesn't modify state
* - Returns default value (address(0)) if entry doesn't exist
* - Used for permission checks and relationship verification
*/
function getStorage(AddressData storage self, bytes memory key, bytes memory innerKey) internal view returns (address) {
return self._storage[key][innerKey];
}
/**
* @dev Delete address value from storage
* Removes an address value from a specific key pair in storage
*
* @param self Storage structure reference
* @param key Primary key for categorization
* @param innerKey Secondary key for specific relationship
*
* @custom:effects
* - Removes value from storage, setting it to default value (address(0))
* - Gas refund is provided when clearing storage to zero
* - Important for revoking permissions or updating relationships
*/
function delStorage(AddressData storage self, bytes memory key, bytes memory innerKey) internal {
delete self._storage[key][innerKey];
}
/**
* @dev Set bytes value in storage
* Assigns a bytes value to a specific key pair in storage
*
* @param self Storage structure reference
* @param key Primary key for categorization (e.g., data type, record ID)
* @param innerKey Secondary key for specific data (e.g., signature, hash)
* @param value Bytes data to store
*
* @custom:effects
* - Updates storage with new bytes data, overwriting any existing value
* - Dynamically sized data is stored with length prefix
* - Gas cost scales with the size of the bytes array
* - Suitable for arbitrary binary data storage
*/
function setStorage(BytesData storage self, bytes memory key, bytes memory innerKey, bytes memory value) internal {
self._storage[key][innerKey] = value;
}
/**
* @dev Get bytes value from storage
* Retrieves a bytes value from a specific key pair in storage
*
* @param self Storage structure reference
* @param key Primary key for categorization
* @param innerKey Secondary key for specific data
* @return Stored bytes value, or empty bytes if no value has been set
*
* @custom:effects
* - Read-only operation that doesn't modify state
* - Returns default value (empty bytes) if entry doesn't exist
* - Gas cost scales with the size of the retrieved data
* - Used for retrieving serialized data, proofs, or signatures
*/
function getStorage(BytesData storage self, bytes memory key, bytes memory innerKey) internal view returns (bytes memory) {
return self._storage[key][innerKey];
}
/**
* @dev Delete bytes value from storage
* Removes a bytes value from a specific key pair in storage
*
* @param self Storage structure reference
* @param key Primary key for categorization
* @param innerKey Secondary key for specific data
*
* @custom:effects
* - Removes value from storage, setting it to default value (empty bytes)
* - Gas refund is provided when clearing storage
* - More gas efficient for larger data due to storage refunds
* - Complete removal of variable-length data
*/
function delStorage(BytesData storage self, bytes memory key, bytes memory innerKey) internal {
delete self._storage[key][innerKey];
}
/**
* @dev Set string value in storage
* Assigns a string value to a specific key pair in storage
*
* @param self Storage structure reference
* @param key Primary key for categorization (e.g., metadata type, record ID)
* @param innerKey Secondary key for specific text (e.g., name, description)
* @param value String data to store
*
* @custom:effects
* - Updates storage with new string, overwriting any existing value
* - Strings are stored as UTF-8 encoded bytes with length prefix
* - Gas cost scales with the length of the string
* - Ideal for human-readable text storage
*/
function setStorage(StringData storage self, bytes memory key, bytes memory innerKey, string memory value) internal {
self._storage[key][innerKey] = value;
}
/**
* @dev Get string value from storage
* Retrieves a string value from a specific key pair in storage
*
* @param self Storage structure reference
* @param key Primary key for categorization
* @param innerKey Secondary key for specific text
* @return Stored string value, or empty string if no value has been set
*
* @custom:effects
* - Read-only operation that doesn't modify state
* - Returns default value (empty string) if entry doesn't exist
* - Gas cost scales with the length of the retrieved string
* - Used for retrieving human-readable configuration and metadata
*/
function getStorage(StringData storage self, bytes memory key, bytes memory innerKey) internal view returns (string memory) {
return self._storage[key][innerKey];
}
/**
* @dev Delete string value from storage
* Removes a string value from a specific key pair in storage
*
* @param self Storage structure reference
* @param key Primary key for categorization
* @param innerKey Secondary key for specific text
*
* @custom:effects
* - Removes value from storage, setting it to default value (empty string)
* - Gas refund is provided when clearing storage
* - More gas efficient for longer strings due to storage refunds
* - Complete removal of variable-length text data
*/
function delStorage(StringData storage self, bytes memory key, bytes memory innerKey) internal {
delete self._storage[key][innerKey];
}
}// SPDX-License-Identifier: MIT
/*
Copyright 2023 Wanchain Foundation.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// _ _ _
// __ ____ _ _ __ ___| |__ __ _(_)_ __ __| | _____ __
// \ \ /\ / / _` | '_ \ / __| '_ \ / _` | | '_ \@/ _` |/ _ \ \ / /
// \ V V / (_| | | | | (__| | | | (_| | | | | | (_| | __/\ V /
// \_/\_/ \__,_|_| |_|\___|_| |_|\__,_|_|_| |_|\__,_|\___| \_/
//
//
pragma solidity ^0.8.18;
import "../components/BasicStorage.sol";
/**
* @title TokenManagerStorage
* @dev Storage contract for token management functionality
* This contract provides:
* - Token pair information storage
* - Ancestor token information storage
* - Token pair mapping and indexing
*/
contract TokenManagerStorage is BasicStorage {
/************************************************************
**
** STRUCTURE DEFINATIONS
**
************************************************************/
/**
* @notice Structure for storing ancestor token information
* @dev Contains basic information about the original token
* @param account Address of the token contract
* @param name Name of the token
* @param symbol Symbol of the token
* @param decimals Number of decimal places
* @param chainID ID of the blockchain where the token originates
*/
struct AncestorInfo {
bytes account;
string name;
string symbol;
uint8 decimals;
uint chainID;
}
/**
* @notice Structure for storing token pair information
* @dev Contains information about token pairs for cross-chain operations
* @param aInfo Information about the ancestor token
* @param fromChainID ID of the source blockchain (e.g., eth=60, etc=61, wan=5718350)
* @param fromAccount Address of the token on the source chain
* @param toChainID ID of the destination blockchain
* @param toAccount Address of the token on the destination chain
*/
struct TokenPairInfo {
AncestorInfo aInfo;
uint fromChainID;
bytes fromAccount;
uint toChainID;
bytes toAccount;
}
/**
* @notice Structure for storing complete token pair information
* @dev Extends TokenPairInfo with a unique identifier
* @param id Unique identifier for the token pair
* @param aInfo Information about the ancestor token
* @param fromChainID ID of the source blockchain
* @param fromAccount Address of the token on the source chain
* @param toChainID ID of the destination blockchain
* @param toAccount Address of the token on the destination chain
*/
struct TokenPairInfoFull {
uint id;
AncestorInfo aInfo;
uint fromChainID;
bytes fromAccount;
uint toChainID;
bytes toAccount;
}
/************************************************************
**
** VARIABLES
**
************************************************************/
/// @notice Total number of token pairs registered in the system
uint public totalTokenPairs = 0;
/// @notice Mapping from token pair ID to token pair information
mapping(uint => TokenPairInfo) public mapTokenPairInfo;
/// @notice Mapping from index to token pair ID for enumeration
mapping(uint => uint) public mapTokenPairIndex;
}{
"optimizer": {
"enabled": true,
"runs": 200
},
"evmVersion": "paris",
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}Contract ABI
API[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"admin","type":"address"}],"name":"AddAdmin","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"admin","type":"address"}],"name":"RemoveAdmin","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"admin","type":"address"}],"name":"addAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"changeOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"implementation","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"mapAdmin","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"mapTokenPairIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"mapTokenPairInfo","outputs":[{"components":[{"internalType":"bytes","name":"account","type":"bytes"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"uint8","name":"decimals","type":"uint8"},{"internalType":"uint256","name":"chainID","type":"uint256"}],"internalType":"struct TokenManagerStorage.AncestorInfo","name":"aInfo","type":"tuple"},{"internalType":"uint256","name":"fromChainID","type":"uint256"},{"internalType":"bytes","name":"fromAccount","type":"bytes"},{"internalType":"uint256","name":"toChainID","type":"uint256"},{"internalType":"bytes","name":"toAccount","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"newOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"admin","type":"address"}],"name":"removeAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"totalTokenPairs","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"impl","type":"address"}],"name":"upgradeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]Contract Creation Code
6080604052600060055534801561001557600080fd5b50600880546001600160a01b03191633179055610c51806100376000396000f3fe6080604052600436106100e15760003560e01c8063715018a61161007f578063a6f9dae111610059578063a6f9dae114610265578063d0ad718d14610285578063d4ee1d901461029b578063d51dddd7146102bb576100f0565b8063715018a61461021b57806379ba5097146102305780638da5cb5b14610245576100f0565b806358a007fb116100bb57806358a007fb146101585780635c60da1b146101985780635d2e9ead146101ca57806370480275146101fb576100f0565b80631785f53c146100f85780633659cfe6146101185780634fb2e45d14610138576100f0565b366100f0576100ee6102fb565b005b6100ee6102fb565b34801561010457600080fd5b506100ee610113366004610a7d565b61037e565b34801561012457600080fd5b506100ee610133366004610a7d565b610400565b34801561014457600080fd5b506100ee610153366004610a7d565b610544565b34801561016457600080fd5b50610185610173366004610aad565b60076020526000908152604090205481565b6040519081526020015b60405180910390f35b3480156101a457600080fd5b50600b546001600160a01b03165b6040516001600160a01b03909116815260200161018f565b3480156101d657600080fd5b506101ea6101e5366004610aad565b610620565b60405161018f959493929190610b0c565b34801561020757600080fd5b506100ee610216366004610a7d565b610940565b34801561022757600080fd5b506100ee6109be565b34801561023c57600080fd5b506100ee6109fa565b34801561025157600080fd5b506008546101b2906001600160a01b031681565b34801561027157600080fd5b506100ee610280366004610a7d565b610a31565b34801561029157600080fd5b5061018560055481565b3480156102a757600080fd5b506009546101b2906001600160a01b031681565b3480156102c757600080fd5b506102eb6102d6366004610a7d565b600a6020526000908152604090205460ff1681565b604051901515815260200161018f565b600b546001600160a01b0316806103595760405162461bcd60e51b815260206004820152601f60248201527f696d706c656d656e746174696f6e20636f6e7472616374206e6f74207365740060448201526064015b60405180910390fd5b60405136600082376000803683855af43d806000843e81801561037a578184f35b8184fd5b6008546001600160a01b031633146103a85760405162461bcd60e51b815260040161035090610bbe565b6001600160a01b0381166000818152600a6020908152604091829020805460ff1916905590519182527f753f40ca3312b2408759a67875b367955e7baa221daf08aa3d643d96202ac12b91015b60405180910390a150565b6008546001600160a01b0316331461042a5760405162461bcd60e51b815260040161035090610bbe565b6001600160a01b03811661048a5760405162461bcd60e51b815260206004820152602160248201527f43616e6e6f74207570677261646520746f20696e76616c6964206164647265736044820152607360f81b6064820152608401610350565b600b546001600160a01b03908116908216036104fa5760405162461bcd60e51b815260206004820152602960248201527f43616e6e6f74207570677261646520746f207468652073616d6520696d706c6560448201526836b2b73a30ba34b7b760b91b6064820152608401610350565b600b80546001600160a01b0319166001600160a01b0383169081179091556040517fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6008546001600160a01b0316331461056e5760405162461bcd60e51b815260040161035090610bbe565b6001600160a01b0381166105c45760405162461bcd60e51b815260206004820152601d60248201527f4e6577206f776e657220697320746865207a65726f20616464726573730000006044820152606401610350565b6008546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600880546001600160a01b0319166001600160a01b0392909216919091179055565b6006602052806000526040600020600091509050806000016040518060a001604052908160008201805461065390610be1565b80601f016020809104026020016040519081016040528092919081815260200182805461067f90610be1565b80156106cc5780601f106106a1576101008083540402835291602001916106cc565b820191906000526020600020905b8154815290600101906020018083116106af57829003601f168201915b505050505081526020016001820180546106e590610be1565b80601f016020809104026020016040519081016040528092919081815260200182805461071190610be1565b801561075e5780601f106107335761010080835404028352916020019161075e565b820191906000526020600020905b81548152906001019060200180831161074157829003601f168201915b5050505050815260200160028201805461077790610be1565b80601f01602080910402602001604051908101604052809291908181526020018280546107a390610be1565b80156107f05780601f106107c5576101008083540402835291602001916107f0565b820191906000526020600020905b8154815290600101906020018083116107d357829003601f168201915b5050509183525050600382015460ff16602082015260049091015460409091015260058201546006830180549293919261082990610be1565b80601f016020809104026020016040519081016040528092919081815260200182805461085590610be1565b80156108a25780601f10610877576101008083540402835291602001916108a2565b820191906000526020600020905b81548152906001019060200180831161088557829003601f168201915b5050505050908060070154908060080180546108bd90610be1565b80601f01602080910402602001604051908101604052809291908181526020018280546108e990610be1565b80156109365780601f1061090b57610100808354040283529160200191610936565b820191906000526020600020905b81548152906001019060200180831161091957829003601f168201915b5050505050905085565b6008546001600160a01b0316331461096a5760405162461bcd60e51b815260040161035090610bbe565b6001600160a01b0381166000818152600a6020908152604091829020805460ff1916600117905590519182527fad6de4452a631e641cb59902236607946ce9272b9b981f2f80e8d129cb9084ba91016103f5565b6008546001600160a01b031633146109e85760405162461bcd60e51b815260040161035090610bbe565b600880546001600160a01b0319169055565b6009546001600160a01b03163303610a2f57600954600880546001600160a01b0319166001600160a01b039092169190911790555b565b6008546001600160a01b03163314610a5b5760405162461bcd60e51b815260040161035090610bbe565b600980546001600160a01b0319166001600160a01b0392909216919091179055565b600060208284031215610a8f57600080fd5b81356001600160a01b0381168114610aa657600080fd5b9392505050565b600060208284031215610abf57600080fd5b5035919050565b6000815180845260005b81811015610aec57602081850181015186830182015201610ad0565b506000602082860101526020601f19601f83011685010191505092915050565b60a081526000865160a080840152610b28610140840182610ac6565b90506020880151609f19808584030160c0860152610b468383610ac6565b925060408a01519150808584030160e086015250610b648282610ac6565b91505060ff60608901511661010084015260808801516101208401528660208401528281036040840152610b988187610ac6565b90508460608401528281036080840152610bb28185610ac6565b98975050505050505050565b6020808252600990820152682737ba1037bbb732b960b91b604082015260600190565b600181811c90821680610bf557607f821691505b602082108103610c1557634e487b7160e01b600052602260045260246000fd5b5091905056fea26469706673582212201082493499147a0db0e1beaaa6c918a126d6ba340f4eb3cd721adfff3c985e0b64736f6c63430008120033
Deployed Bytecode
0x6080604052600436106100e15760003560e01c8063715018a61161007f578063a6f9dae111610059578063a6f9dae114610265578063d0ad718d14610285578063d4ee1d901461029b578063d51dddd7146102bb576100f0565b8063715018a61461021b57806379ba5097146102305780638da5cb5b14610245576100f0565b806358a007fb116100bb57806358a007fb146101585780635c60da1b146101985780635d2e9ead146101ca57806370480275146101fb576100f0565b80631785f53c146100f85780633659cfe6146101185780634fb2e45d14610138576100f0565b366100f0576100ee6102fb565b005b6100ee6102fb565b34801561010457600080fd5b506100ee610113366004610a7d565b61037e565b34801561012457600080fd5b506100ee610133366004610a7d565b610400565b34801561014457600080fd5b506100ee610153366004610a7d565b610544565b34801561016457600080fd5b50610185610173366004610aad565b60076020526000908152604090205481565b6040519081526020015b60405180910390f35b3480156101a457600080fd5b50600b546001600160a01b03165b6040516001600160a01b03909116815260200161018f565b3480156101d657600080fd5b506101ea6101e5366004610aad565b610620565b60405161018f959493929190610b0c565b34801561020757600080fd5b506100ee610216366004610a7d565b610940565b34801561022757600080fd5b506100ee6109be565b34801561023c57600080fd5b506100ee6109fa565b34801561025157600080fd5b506008546101b2906001600160a01b031681565b34801561027157600080fd5b506100ee610280366004610a7d565b610a31565b34801561029157600080fd5b5061018560055481565b3480156102a757600080fd5b506009546101b2906001600160a01b031681565b3480156102c757600080fd5b506102eb6102d6366004610a7d565b600a6020526000908152604090205460ff1681565b604051901515815260200161018f565b600b546001600160a01b0316806103595760405162461bcd60e51b815260206004820152601f60248201527f696d706c656d656e746174696f6e20636f6e7472616374206e6f74207365740060448201526064015b60405180910390fd5b60405136600082376000803683855af43d806000843e81801561037a578184f35b8184fd5b6008546001600160a01b031633146103a85760405162461bcd60e51b815260040161035090610bbe565b6001600160a01b0381166000818152600a6020908152604091829020805460ff1916905590519182527f753f40ca3312b2408759a67875b367955e7baa221daf08aa3d643d96202ac12b91015b60405180910390a150565b6008546001600160a01b0316331461042a5760405162461bcd60e51b815260040161035090610bbe565b6001600160a01b03811661048a5760405162461bcd60e51b815260206004820152602160248201527f43616e6e6f74207570677261646520746f20696e76616c6964206164647265736044820152607360f81b6064820152608401610350565b600b546001600160a01b03908116908216036104fa5760405162461bcd60e51b815260206004820152602960248201527f43616e6e6f74207570677261646520746f207468652073616d6520696d706c6560448201526836b2b73a30ba34b7b760b91b6064820152608401610350565b600b80546001600160a01b0319166001600160a01b0383169081179091556040517fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6008546001600160a01b0316331461056e5760405162461bcd60e51b815260040161035090610bbe565b6001600160a01b0381166105c45760405162461bcd60e51b815260206004820152601d60248201527f4e6577206f776e657220697320746865207a65726f20616464726573730000006044820152606401610350565b6008546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600880546001600160a01b0319166001600160a01b0392909216919091179055565b6006602052806000526040600020600091509050806000016040518060a001604052908160008201805461065390610be1565b80601f016020809104026020016040519081016040528092919081815260200182805461067f90610be1565b80156106cc5780601f106106a1576101008083540402835291602001916106cc565b820191906000526020600020905b8154815290600101906020018083116106af57829003601f168201915b505050505081526020016001820180546106e590610be1565b80601f016020809104026020016040519081016040528092919081815260200182805461071190610be1565b801561075e5780601f106107335761010080835404028352916020019161075e565b820191906000526020600020905b81548152906001019060200180831161074157829003601f168201915b5050505050815260200160028201805461077790610be1565b80601f01602080910402602001604051908101604052809291908181526020018280546107a390610be1565b80156107f05780601f106107c5576101008083540402835291602001916107f0565b820191906000526020600020905b8154815290600101906020018083116107d357829003601f168201915b5050509183525050600382015460ff16602082015260049091015460409091015260058201546006830180549293919261082990610be1565b80601f016020809104026020016040519081016040528092919081815260200182805461085590610be1565b80156108a25780601f10610877576101008083540402835291602001916108a2565b820191906000526020600020905b81548152906001019060200180831161088557829003601f168201915b5050505050908060070154908060080180546108bd90610be1565b80601f01602080910402602001604051908101604052809291908181526020018280546108e990610be1565b80156109365780601f1061090b57610100808354040283529160200191610936565b820191906000526020600020905b81548152906001019060200180831161091957829003601f168201915b5050505050905085565b6008546001600160a01b0316331461096a5760405162461bcd60e51b815260040161035090610bbe565b6001600160a01b0381166000818152600a6020908152604091829020805460ff1916600117905590519182527fad6de4452a631e641cb59902236607946ce9272b9b981f2f80e8d129cb9084ba91016103f5565b6008546001600160a01b031633146109e85760405162461bcd60e51b815260040161035090610bbe565b600880546001600160a01b0319169055565b6009546001600160a01b03163303610a2f57600954600880546001600160a01b0319166001600160a01b039092169190911790555b565b6008546001600160a01b03163314610a5b5760405162461bcd60e51b815260040161035090610bbe565b600980546001600160a01b0319166001600160a01b0392909216919091179055565b600060208284031215610a8f57600080fd5b81356001600160a01b0381168114610aa657600080fd5b9392505050565b600060208284031215610abf57600080fd5b5035919050565b6000815180845260005b81811015610aec57602081850181015186830182015201610ad0565b506000602082860101526020601f19601f83011685010191505092915050565b60a081526000865160a080840152610b28610140840182610ac6565b90506020880151609f19808584030160c0860152610b468383610ac6565b925060408a01519150808584030160e086015250610b648282610ac6565b91505060ff60608901511661010084015260808801516101208401528660208401528281036040840152610b988187610ac6565b90508460608401528281036080840152610bb28185610ac6565b98975050505050505050565b6020808252600990820152682737ba1037bbb732b960b91b604082015260600190565b600181811c90821680610bf557607f821691505b602082108103610c1557634e487b7160e01b600052602260045260246000fd5b5091905056fea26469706673582212201082493499147a0db0e1beaaa6c918a126d6ba340f4eb3cd721adfff3c985e0b64736f6c63430008120033
Loading...
Loading
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.