refactor: move brother_node development artifact to dev/test-nodes subdirectory
Development Artifact Cleanup: ✅ BROTHER_NODE REORGANIZATION: Moved development test node to appropriate location - dev/test-nodes/brother_node/: Moved from root directory for better organization - Contains development configuration, test logs, and test chain data - No impact on production systems - purely development/testing artifact ✅ DEVELOPMENT ARTIFACTS IDENTIFIED: - Chain ID: aitbc-brother-chain (test/development chain) - Ports: 8010 (P2P) and 8011 (RPC) - different from production - Environment: .env file with test configuration - Logs: rpc.log and node.log from development testing session (March 15, 2026) ✅ ROOT DIRECTORY CLEANUP: Removed development clutter from production directory - brother_node/ moved to dev/test-nodes/brother_node/ - Root directory now contains only production-ready components - Development artifacts properly organized in dev/ subdirectory DIRECTORY STRUCTURE IMPROVEMENT: 📁 dev/test-nodes/: Development and testing node configurations 🏗️ Root Directory: Clean production structure with only essential components 🧪 Development Isolation: Test environments separated from production BENEFITS: ✅ Clean Production Directory: No development artifacts in root ✅ Better Organization: Development nodes grouped in dev/ subdirectory ✅ Clear Separation: Production vs development environments clearly distinguished ✅ Maintainability: Easier to identify and manage development components RESULT: Successfully moved brother_node development artifact to dev/test-nodes/ subdirectory, cleaning up the root directory while preserving development testing environment for future use.
This commit is contained in:
95
dev/env/node_modules/@openzeppelin/contracts/token/ERC20/utils/ERC1363Utils.sol
generated
vendored
Executable file
95
dev/env/node_modules/@openzeppelin/contracts/token/ERC20/utils/ERC1363Utils.sol
generated
vendored
Executable file
@@ -0,0 +1,95 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/utils/ERC1363Utils.sol)
|
||||
|
||||
pragma solidity ^0.8.20;
|
||||
|
||||
import {IERC1363Receiver} from "../../../interfaces/IERC1363Receiver.sol";
|
||||
import {IERC1363Spender} from "../../../interfaces/IERC1363Spender.sol";
|
||||
|
||||
/**
|
||||
* @dev Library that provides common ERC-1363 utility functions.
|
||||
*
|
||||
* See https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
|
||||
*/
|
||||
library ERC1363Utils {
|
||||
/**
|
||||
* @dev Indicates a failure with the token `receiver`. Used in transfers.
|
||||
* @param receiver Address to which tokens are being transferred.
|
||||
*/
|
||||
error ERC1363InvalidReceiver(address receiver);
|
||||
|
||||
/**
|
||||
* @dev Indicates a failure with the token `spender`. Used in approvals.
|
||||
* @param spender Address that may be allowed to operate on tokens without being their owner.
|
||||
*/
|
||||
error ERC1363InvalidSpender(address spender);
|
||||
|
||||
/**
|
||||
* @dev Performs a call to {IERC1363Receiver-onTransferReceived} on a target address.
|
||||
*
|
||||
* Requirements:
|
||||
*
|
||||
* - The target has code (i.e. is a contract).
|
||||
* - The target `to` must implement the {IERC1363Receiver} interface.
|
||||
* - The target must return the {IERC1363Receiver-onTransferReceived} selector to accept the transfer.
|
||||
*/
|
||||
function checkOnERC1363TransferReceived(
|
||||
address operator,
|
||||
address from,
|
||||
address to,
|
||||
uint256 value,
|
||||
bytes memory data
|
||||
) internal {
|
||||
if (to.code.length == 0) {
|
||||
revert ERC1363InvalidReceiver(to);
|
||||
}
|
||||
|
||||
try IERC1363Receiver(to).onTransferReceived(operator, from, value, data) returns (bytes4 retval) {
|
||||
if (retval != IERC1363Receiver.onTransferReceived.selector) {
|
||||
revert ERC1363InvalidReceiver(to);
|
||||
}
|
||||
} catch (bytes memory reason) {
|
||||
if (reason.length == 0) {
|
||||
revert ERC1363InvalidReceiver(to);
|
||||
} else {
|
||||
assembly ("memory-safe") {
|
||||
revert(add(reason, 0x20), mload(reason))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Performs a call to {IERC1363Spender-onApprovalReceived} on a target address.
|
||||
*
|
||||
* Requirements:
|
||||
*
|
||||
* - The target has code (i.e. is a contract).
|
||||
* - The target `spender` must implement the {IERC1363Spender} interface.
|
||||
* - The target must return the {IERC1363Spender-onApprovalReceived} selector to accept the approval.
|
||||
*/
|
||||
function checkOnERC1363ApprovalReceived(
|
||||
address operator,
|
||||
address spender,
|
||||
uint256 value,
|
||||
bytes memory data
|
||||
) internal {
|
||||
if (spender.code.length == 0) {
|
||||
revert ERC1363InvalidSpender(spender);
|
||||
}
|
||||
|
||||
try IERC1363Spender(spender).onApprovalReceived(operator, value, data) returns (bytes4 retval) {
|
||||
if (retval != IERC1363Spender.onApprovalReceived.selector) {
|
||||
revert ERC1363InvalidSpender(spender);
|
||||
}
|
||||
} catch (bytes memory reason) {
|
||||
if (reason.length == 0) {
|
||||
revert ERC1363InvalidSpender(spender);
|
||||
} else {
|
||||
assembly ("memory-safe") {
|
||||
revert(add(reason, 0x20), mload(reason))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
212
dev/env/node_modules/@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol
generated
vendored
Executable file
212
dev/env/node_modules/@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol
generated
vendored
Executable file
@@ -0,0 +1,212 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// OpenZeppelin Contracts (last updated v5.3.0) (token/ERC20/utils/SafeERC20.sol)
|
||||
|
||||
pragma solidity ^0.8.20;
|
||||
|
||||
import {IERC20} from "../IERC20.sol";
|
||||
import {IERC1363} from "../../../interfaces/IERC1363.sol";
|
||||
|
||||
/**
|
||||
* @title SafeERC20
|
||||
* @dev Wrappers around ERC-20 operations that throw on failure (when the token
|
||||
* contract returns false). Tokens that return no value (and instead revert or
|
||||
* throw on failure) are also supported, non-reverting calls are assumed to be
|
||||
* successful.
|
||||
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
|
||||
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
|
||||
*/
|
||||
library SafeERC20 {
|
||||
/**
|
||||
* @dev An operation with an ERC-20 token failed.
|
||||
*/
|
||||
error SafeERC20FailedOperation(address token);
|
||||
|
||||
/**
|
||||
* @dev Indicates a failed `decreaseAllowance` request.
|
||||
*/
|
||||
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
|
||||
|
||||
/**
|
||||
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
|
||||
* non-reverting calls are assumed to be successful.
|
||||
*/
|
||||
function safeTransfer(IERC20 token, address to, uint256 value) internal {
|
||||
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
|
||||
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
|
||||
*/
|
||||
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
|
||||
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Variant of {safeTransfer} that returns a bool instead of reverting if the operation is not successful.
|
||||
*/
|
||||
function trySafeTransfer(IERC20 token, address to, uint256 value) internal returns (bool) {
|
||||
return _callOptionalReturnBool(token, abi.encodeCall(token.transfer, (to, value)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Variant of {safeTransferFrom} that returns a bool instead of reverting if the operation is not successful.
|
||||
*/
|
||||
function trySafeTransferFrom(IERC20 token, address from, address to, uint256 value) internal returns (bool) {
|
||||
return _callOptionalReturnBool(token, abi.encodeCall(token.transferFrom, (from, to, value)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
|
||||
* non-reverting calls are assumed to be successful.
|
||||
*
|
||||
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
|
||||
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
|
||||
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
|
||||
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
|
||||
*/
|
||||
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
|
||||
uint256 oldAllowance = token.allowance(address(this), spender);
|
||||
forceApprove(token, spender, oldAllowance + value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
|
||||
* value, non-reverting calls are assumed to be successful.
|
||||
*
|
||||
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
|
||||
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
|
||||
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
|
||||
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
|
||||
*/
|
||||
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
|
||||
unchecked {
|
||||
uint256 currentAllowance = token.allowance(address(this), spender);
|
||||
if (currentAllowance < requestedDecrease) {
|
||||
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
|
||||
}
|
||||
forceApprove(token, spender, currentAllowance - requestedDecrease);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
|
||||
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
|
||||
* to be set to zero before setting it to a non-zero value, such as USDT.
|
||||
*
|
||||
* NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
|
||||
* only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
|
||||
* set here.
|
||||
*/
|
||||
function forceApprove(IERC20 token, address spender, uint256 value) internal {
|
||||
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
|
||||
|
||||
if (!_callOptionalReturnBool(token, approvalCall)) {
|
||||
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
|
||||
_callOptionalReturn(token, approvalCall);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
|
||||
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
|
||||
* targeting contracts.
|
||||
*
|
||||
* Reverts if the returned value is other than `true`.
|
||||
*/
|
||||
function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
|
||||
if (to.code.length == 0) {
|
||||
safeTransfer(token, to, value);
|
||||
} else if (!token.transferAndCall(to, value, data)) {
|
||||
revert SafeERC20FailedOperation(address(token));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
|
||||
* has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
|
||||
* targeting contracts.
|
||||
*
|
||||
* Reverts if the returned value is other than `true`.
|
||||
*/
|
||||
function transferFromAndCallRelaxed(
|
||||
IERC1363 token,
|
||||
address from,
|
||||
address to,
|
||||
uint256 value,
|
||||
bytes memory data
|
||||
) internal {
|
||||
if (to.code.length == 0) {
|
||||
safeTransferFrom(token, from, to, value);
|
||||
} else if (!token.transferFromAndCall(from, to, value, data)) {
|
||||
revert SafeERC20FailedOperation(address(token));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
|
||||
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
|
||||
* targeting contracts.
|
||||
*
|
||||
* NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
|
||||
* Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
|
||||
* once without retrying, and relies on the returned value to be true.
|
||||
*
|
||||
* Reverts if the returned value is other than `true`.
|
||||
*/
|
||||
function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
|
||||
if (to.code.length == 0) {
|
||||
forceApprove(token, to, value);
|
||||
} else if (!token.approveAndCall(to, value, data)) {
|
||||
revert SafeERC20FailedOperation(address(token));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
|
||||
* on the return value: the return value is optional (but if data is returned, it must not be false).
|
||||
* @param token The token targeted by the call.
|
||||
* @param data The call data (encoded using abi.encode or one of its variants).
|
||||
*
|
||||
* This is a variant of {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
|
||||
*/
|
||||
function _callOptionalReturn(IERC20 token, bytes memory data) private {
|
||||
uint256 returnSize;
|
||||
uint256 returnValue;
|
||||
assembly ("memory-safe") {
|
||||
let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
|
||||
// bubble errors
|
||||
if iszero(success) {
|
||||
let ptr := mload(0x40)
|
||||
returndatacopy(ptr, 0, returndatasize())
|
||||
revert(ptr, returndatasize())
|
||||
}
|
||||
returnSize := returndatasize()
|
||||
returnValue := mload(0)
|
||||
}
|
||||
|
||||
if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
|
||||
revert SafeERC20FailedOperation(address(token));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
|
||||
* on the return value: the return value is optional (but if data is returned, it must not be false).
|
||||
* @param token The token targeted by the call.
|
||||
* @param data The call data (encoded using abi.encode or one of its variants).
|
||||
*
|
||||
* This is a variant of {_callOptionalReturn} that silently catches all reverts and returns a bool instead.
|
||||
*/
|
||||
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
|
||||
bool success;
|
||||
uint256 returnSize;
|
||||
uint256 returnValue;
|
||||
assembly ("memory-safe") {
|
||||
success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
|
||||
returnSize := returndatasize()
|
||||
returnValue := mload(0)
|
||||
}
|
||||
return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user