// SPDX-License-Identifier: MITpragmasolidity ^0.8.8;import { UintUtils } from'./UintUtils.sol';
libraryAddressUtils{
usingUintUtilsforuint256;
errorAddressUtils__InsufficientBalance();
errorAddressUtils__NotContract();
errorAddressUtils__SendValueFailed();
functiontoString(address account) internalpurereturns (stringmemory) {
returnuint256(uint160(account)).toHexString(20);
}
functionisContract(address account) internalviewreturns (bool) {
uint256 size;
assembly {
size :=extcodesize(account)
}
return size >0;
}
functionsendValue(addresspayable account, uint256 amount) internal{
(bool success, ) = account.call{ value: amount }('');
if (!success) revert AddressUtils__SendValueFailed();
}
functionfunctionCall(address target,
bytesmemory data
) internalreturns (bytesmemory) {
return
functionCall(target, data, 'AddressUtils: failed low-level call');
}
functionfunctionCall(address target,
bytesmemory data,
stringmemoryerror) internalreturns (bytesmemory) {
return _functionCallWithValue(target, data, 0, error);
}
functionfunctionCallWithValue(address target,
bytesmemory data,
uint256 value
) internalreturns (bytesmemory) {
return
functionCallWithValue(
target,
data,
value,
'AddressUtils: failed low-level call with value'
);
}
functionfunctionCallWithValue(address target,
bytesmemory data,
uint256 value,
stringmemoryerror) internalreturns (bytesmemory) {
if (value >address(this).balance)
revert AddressUtils__InsufficientBalance();
return _functionCallWithValue(target, data, value, error);
}
/**
* @notice execute arbitrary external call with limited gas usage and amount of copied return data
* @dev derived from https://github.com/nomad-xyz/ExcessivelySafeCall (MIT License)
* @param target recipient of call
* @param gasAmount gas allowance for call
* @param value native token value to include in call
* @param maxCopy maximum number of bytes to copy from return data
* @param data encoded call data
* @return success whether call is successful
* @return returnData copied return data
*/functionexcessivelySafeCall(address target,
uint256 gasAmount,
uint256 value,
uint16 maxCopy,
bytesmemory data
) internalreturns (bool success, bytesmemory returnData) {
returnData =newbytes(maxCopy);
assembly {
// execute external call via assembly to avoid automatic copying of return data
success :=call(
gasAmount,
target,
value,
add(data, 0x20),
mload(data),
0,
0
)
// determine whether to limit amount of data to copylet toCopy :=returndatasize()
ifgt(toCopy, maxCopy) {
toCopy := maxCopy
}
// store the length of the copied bytesmstore(returnData, toCopy)
// copy the bytes from returndata[0:toCopy]returndatacopy(add(returnData, 0x20), 0, toCopy)
}
}
function_functionCallWithValue(address target,
bytesmemory data,
uint256 value,
stringmemoryerror) privatereturns (bytesmemory) {
if (!isContract(target)) revert AddressUtils__NotContract();
(bool success, bytesmemory returnData) = target.call{ value: value }(
data
);
if (success) {
return returnData;
} elseif (returnData.length>0) {
assembly {
let returnData_size :=mload(returnData)
revert(add(32, returnData), returnData_size)
}
} else {
revert(error);
}
}
}
Contract Source Code
File 2 of 16: ERC1155MetadataExtensionInternal.sol
// SPDX-License-Identifier: UNLICENSEDpragmasolidity ^0.8.18;import { ERC1155MetadataExtensionStorage } from'./ERC1155MetadataExtensionStorage.sol';
import { IERC1155MetadataExtensionInternal } from'./IERC1155MetadataExtensionInternal.sol';
abstractcontractERC1155MetadataExtensionInternalisIERC1155MetadataExtensionInternal{
/**
* @notice sets a new name for ECR1155 collection
* @param name name to set
*/function_setName(stringmemory name) internal{
ERC1155MetadataExtensionStorage.layout().name= name;
emit NameSet(name);
}
/**
* @notice sets a new symbol for ECR1155 collection
* @param symbol symbol to set
*/function_setSymbol(stringmemory symbol) internal{
ERC1155MetadataExtensionStorage.layout().symbol = symbol;
emit SymbolSet(symbol);
}
/**
* @notice reads ERC1155 collcetion name
* @return name ERC1155 collection name
*/function_name() internalviewreturns (stringmemory name) {
name = ERC1155MetadataExtensionStorage.layout().name;
}
/**
* @notice reads ERC1155 collcetion symbol
* @return symbol ERC1155 collection symbol
*/function_symbol() internalviewreturns (stringmemory symbol) {
symbol = ERC1155MetadataExtensionStorage.layout().symbol;
}
}
// SPDX-License-Identifier: MITpragmasolidity ^0.8.8;/**
* @title Diamond proxy introspection interface
* @dev see https://eips.ethereum.org/EIPS/eip-2535
*/interfaceIDiamondReadable{
structFacet {
address target;
bytes4[] selectors;
}
/**
* @notice get all facets and their selectors
* @return diamondFacets array of structured facet data
*/functionfacets() externalviewreturns (Facet[] memory diamondFacets);
/**
* @notice get all selectors for given facet address
* @param facet address of facet to query
* @return selectors array of function selectors
*/functionfacetFunctionSelectors(address facet
) externalviewreturns (bytes4[] memory selectors);
/**
* @notice get addresses of all facets used by diamond
* @return addresses array of facet addresses
*/functionfacetAddresses()
externalviewreturns (address[] memory addresses);
/**
* @notice get the address of the facet associated with given selector
* @param selector function selector to query
* @return facet facet address (zero address if not found)
*/functionfacetAddress(bytes4 selector
) externalviewreturns (address facet);
}
Contract Source Code
File 6 of 16: IERC1155MetadataExtensionInternal.sol
// SPDX-License-Identifier: UNLICENSEDpragmasolidity ^0.8.18;interfaceIERC1155MetadataExtensionInternal{
/**
* @notice emitted when a name for the ECR1155 collection is set
* @param name set name
*/eventNameSet(string name);
/**
* @notice emitted when a symbol for the ECR1155 collection is set
* @param symbol set symbol
*/eventSymbolSet(string symbol);
}
Contract Source Code
File 7 of 16: IERC173.sol
// SPDX-License-Identifier: MITpragmasolidity ^0.8.8;import { IERC173Internal } from'./IERC173Internal.sol';
/**
* @title Contract ownership standard interface
* @dev see https://eips.ethereum.org/EIPS/eip-173
*/interfaceIERC173isIERC173Internal{
/**
* @notice get the ERC173 contract owner
* @return conrtact owner
*/functionowner() externalviewreturns (address);
/**
* @notice transfer contract ownership to new account
* @param account address of new owner
*/functiontransferOwnership(address account) external;
}