Description:
Multi-signature wallet contract requiring multiple confirmations for transaction execution.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
{{
"language": "Solidity",
"sources": {
"@openzeppelin/contracts/access/Ownable.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @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.
*
* The initial owner is set to the address provided by the deployer. 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.
*/
abstract contract Ownable is Context {
address private _owner;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(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 {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
"
},
"@openzeppelin/contracts/token/ERC721/IERC721.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon
* a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must have been allowed to move this token by either {approve} or
* {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon
* a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
* or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
* understand this adds an external call which potentially creates a reentrancy vulnerability.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the address zero.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
}
"
},
"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.20;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be
* reverted.
*
* The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
"
},
"@openzeppelin/contracts/utils/Context.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
"
},
"@openzeppelin/contracts/utils/introspection/IERC165.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
"
},
"@openzeppelin/contracts/utils/Pausable.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract Pausable is Context {
bool private _paused;
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
/**
* @dev The operation failed because the contract is paused.
*/
error EnforcedPause();
/**
* @dev The operation failed because the contract is not paused.
*/
error ExpectedPause();
/**
* @dev Initializes the contract in unpaused state.
*/
constructor() {
_paused = false;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
if (paused()) {
revert EnforcedPause();
}
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
if (!paused()) {
revert ExpectedPause();
}
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
"
},
"@openzeppelin/contracts/utils/ReentrancyGuard.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant NOT_ENTERED = 1;
uint256 private constant ENTERED = 2;
uint256 private _status;
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
constructor() {
_status = NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be NOT_ENTERED
if (_status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
// Any calls to nonReentrant after this point will fail
_status = ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == ENTERED;
}
}
"
},
"contracts/ERC721InheritanceFactoryV2.sol": {
"content": "// SPDX-License-Identifier: MIT\r
pragma solidity ^0.8.20;\r
\r
import { IERC721 } from "@openzeppelin/contracts/token/ERC721/IERC721.sol";\r
import { IERC721Receiver } from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";\r
import { ReentrancyGuard } from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";\r
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";\r
import { Pausable } from "@openzeppelin/contracts/utils/Pausable.sol";\r
\r
/**\r
* @dev Interfaz mínima para consultar si la Factory está en pausa.\r
*/\r
interface IPausable {\r
function paused() external view returns (bool);\r
}\r
\r
/**\r
* @title ERC721InheritanceFactoryV2\r
* Factory para crear vaults de herencia por NFT (ERC-721).\r
* - Un vault por tokenId.\r
* - La factory es pausable; los vaults respetan esa pausa vía whenFactoryNotPaused.\r
*/\r
contract ERC721InheritanceFactoryV2 is Ownable, Pausable, ReentrancyGuard {\r
// ---------------------------------------------------------------------\r
// Events\r
// ---------------------------------------------------------------------\r
event VaultCreated(\r
address indexed vault,\r
address indexed testator,\r
address indexed heir,\r
address nftContract,\r
uint256 tokenId,\r
uint256 timelockSeconds\r
);\r
\r
event RegistryUpdated(address indexed registry);\r
event CommissionWalletUpdated(address indexed commissionWallet);\r
event FeeBpsUpdated(uint256 feeBps);\r
\r
// ---------------------------------------------------------------------\r
// Storage (Factory)\r
// ---------------------------------------------------------------------\r
address public immutable nftContract; // ERC-721 collection\r
address public commissionWallet; // Metadato (fee fijo futuro)\r
uint256 public feeBps; // Metadato (no aplicado en NFT)\r
address public registry; // Registry BΔLT (metadato / integración)\r
\r
address[] public allVaults;\r
mapping(address => address[]) public vaultsByTestator;\r
\r
// ---------------------------------------------------------------------\r
// Constructor\r
// ---------------------------------------------------------------------\r
constructor(\r
address _commissionWallet,\r
address _nftContract,\r
uint256 _feeBps,\r
address _registry\r
)\r
Ownable(msg.sender) // OZ v5 requiere initialOwner\r
{\r
require(_nftContract != address(0), "NFT contract required");\r
require(_commissionWallet != address(0), "commission wallet required");\r
require(_feeBps <= 10_000, "feeBps > 100%");\r
nftContract = _nftContract;\r
commissionWallet = _commissionWallet;\r
feeBps = _feeBps;\r
registry = _registry;\r
}\r
\r
// ---------------------------------------------------------------------\r
// Admin (owner)\r
// ---------------------------------------------------------------------\r
function setCommissionWallet(address _wallet) external onlyOwner {\r
require(_wallet != address(0), "zero addr");\r
commissionWallet = _wallet;\r
emit CommissionWalletUpdated(_wallet);\r
}\r
\r
function setFeeBps(uint256 _feeBps) external onlyOwner {\r
require(_feeBps <= 10_000, "feeBps > 100%");\r
feeBps = _feeBps;\r
emit FeeBpsUpdated(_feeBps);\r
}\r
\r
function setRegistry(address _registry) external onlyOwner {\r
registry = _registry;\r
emit RegistryUpdated(_registry);\r
}\r
\r
function pause() external onlyOwner { _pause(); }\r
function unpause() external onlyOwner { _unpause(); }\r
\r
// ---------------------------------------------------------------------\r
// Views\r
// ---------------------------------------------------------------------\r
function allVaultsLength() external view returns (uint256) {\r
return allVaults.length;\r
}\r
\r
function vaultsOf(address testator) external view returns (address[] memory) {\r
return vaultsByTestator[testator];\r
}\r
\r
// ---------------------------------------------------------------------\r
// Create Vault\r
// ---------------------------------------------------------------------\r
function createVault(\r
address heir,\r
uint256 tokenId,\r
uint256 timelockSeconds\r
) external whenNotPaused nonReentrant returns (address vault) {\r
require(heir != address(0), "invalid heir");\r
require(timelockSeconds > 0, "timelock=0");\r
\r
ERC721InheritanceVaultV2 v = new ERC721InheritanceVaultV2(\r
msg.sender,\r
heir,\r
nftContract,\r
tokenId,\r
timelockSeconds,\r
address(this) // factory\r
);\r
vault = address(v);\r
\r
allVaults.push(vault);\r
vaultsByTestator[msg.sender].push(vault);\r
\r
emit VaultCreated(\r
vault,\r
msg.sender,\r
heir,\r
nftContract,\r
tokenId,\r
timelockSeconds\r
);\r
}\r
}\r
\r
/**\r
* @title ERC721InheritanceVaultV2\r
* Un vault por NFT (tokenId) para herencia con timelock.\r
*\r
* Reglas:\r
* - Timelock cuenta desde lockedAt (momento del lock real).\r
* - claim() sólo si lockedAt != 0, isLocked == true y pasó el timelock.\r
* - revoke() devuelve el NFT al testator y limpia lockedAt/isLocked.\r
* - setHeir() y extendTimelock() permitidos antes de claim.\r
* - Respeta pausa de la Factory con whenFactoryNotPaused.\r
* - Depósitos sólo válidos a través de lockAsset() (acceptingLock).\r
*/\r
contract ERC721InheritanceVaultV2 is IERC721Receiver, ReentrancyGuard {\r
// ---------------------------------------------------------------------\r
// Events\r
// ---------------------------------------------------------------------\r
event Locked(address indexed testator, address indexed nft, uint256 indexed tokenId);\r
event Claimed(address indexed heir, address indexed nft, uint256 indexed tokenId);\r
event Revoked(address indexed testator, address indexed nft, uint256 indexed tokenId);\r
event HeirUpdated(address indexed oldHeir, address indexed newHeir);\r
event TimelockExtended(uint256 oldTimelock, uint256 newTimelock);\r
\r
// ---------------------------------------------------------------------\r
// Immutable / Factory references\r
// ---------------------------------------------------------------------\r
address public immutable factory; // ERC721InheritanceFactoryV2\r
address public immutable nftContract; // ERC-721 collection\r
uint256 public immutable tokenId; // tokenId objetivo de este vault\r
\r
// ---------------------------------------------------------------------\r
// State\r
// ---------------------------------------------------------------------\r
address public testator; // Creador del vault y propietario original del NFT\r
address public heir; // Heredero designado\r
uint256 public createdAt; // Timestamp de creación del vault\r
uint256 public timelockSeconds; // Duración del timelock\r
uint256 public lockedAt; // Timestamp cuando el NFT quedó lockeado (0 si no está lockeado)\r
bool public isLocked; // true si el NFT está en el vault\r
bool public isClaimed; // true si ya se hizo claim (finaliza el ciclo)\r
bool private acceptingLock; // permite depósito solo desde lockAsset()\r
\r
// ---------------------------------------------------------------------\r
// Modifiers\r
// ---------------------------------------------------------------------\r
modifier onlyTestator() {\r
require(msg.sender == testator, "not testator");\r
_;\r
}\r
\r
modifier onlyHeir() {\r
require(msg.sender == heir, "not heir");\r
_;\r
}\r
\r
modifier whenFactoryNotPaused() {\r
require(!IPausable(factory).paused(), "factory paused");\r
_;\r
}\r
\r
// ---------------------------------------------------------------------\r
// Constructor\r
// ---------------------------------------------------------------------\r
constructor(\r
address _testator,\r
address _heir,\r
address _nftContract,\r
uint256 _tokenId,\r
uint256 _timelockSeconds,\r
address _factory\r
) {\r
require(_testator != address(0), "testator=0");\r
require(_heir != address(0), "heir=0");\r
require(_nftContract != address(0), "nft=0");\r
require(_timelockSeconds > 0, "timelock=0");\r
require(_factory != address(0), "factory=0");\r
\r
testator = _testator;\r
heir = _heir;\r
nftContract = _nftContract;\r
tokenId = _tokenId;\r
timelockSeconds = _timelockSeconds;\r
factory = _factory;\r
createdAt = block.timestamp;\r
}\r
\r
// ---------------------------------------------------------------------\r
// User actions\r
// ---------------------------------------------------------------------\r
\r
/**\r
* @notice El testator transfiere el NFT al vault. Requiere aprobación previa.\r
* Solo se acepta depósito iniciado por esta función (acceptingLock).\r
*/\r
function lockAsset() external onlyTestator whenFactoryNotPaused nonReentrant {\r
require(!isClaimed, "already claimed");\r
require(!isLocked, "already locked");\r
\r
acceptingLock = true;\r
IERC721(nftContract).safeTransferFrom(testator, address(this), tokenId);\r
acceptingLock = false;\r
\r
isLocked = true;\r
lockedAt = block.timestamp;\r
emit Locked(testator, nftContract, tokenId);\r
}\r
\r
/**\r
* @notice El heredero reclama el NFT si pasó el timelock y el NFT está lockeado.\r
* Timelock cuenta desde lockedAt.\r
*/\r
function claim() external onlyHeir whenFactoryNotPaused nonReentrant {\r
require(!isClaimed, "already claimed");\r
require(isLocked, "not locked");\r
require(lockedAt != 0, "not locked yet");\r
require(block.timestamp >= lockedAt + timelockSeconds, "timelock not reached");\r
\r
isClaimed = true;\r
IERC721(nftContract).safeTransferFrom(address(this), heir, tokenId);\r
emit Claimed(heir, nftContract, tokenId);\r
}\r
\r
/**\r
* @notice El testator puede revocar y recuperar el NFT si aún no se reclamó.\r
* Limpia lockedAt e isLocked.\r
*/\r
function revoke() external onlyTestator whenFactoryNotPaused nonReentrant {\r
require(!isClaimed, "already claimed");\r
require(isLocked, "not locked");\r
\r
IERC721(nftContract).safeTransferFrom(address(this), testator, tokenId);\r
isLocked = false;\r
lockedAt = 0;\r
\r
emit Revoked(testator, nftContract, tokenId);\r
}\r
\r
/**\r
* @notice El testator puede cambiar el heredero mientras no se haya hecho claim.\r
*/\r
function setHeir(address newHeir) external onlyTestator whenFactoryNotPaused {\r
require(!isClaimed, "already claimed");\r
require(newHeir != address(0), "heir=0");\r
\r
address old = heir;\r
heir = newHeir;\r
\r
emit HeirUpdated(old, newHeir);\r
}\r
\r
/**\r
* @notice El testator puede EXTENDER (no reducir) el timelock.\r
*/\r
function extendTimelock(uint256 newTimelockSeconds) external onlyTestator whenFactoryNotPaused {\r
require(newTimelockSeconds > timelockSeconds, "must extend");\r
\r
uint256 old = timelockSeconds;\r
timelockSeconds = newTimelockSeconds;\r
\r
emit TimelockExtended(old, newTimelockSeconds);\r
}\r
\r
// ---------------------------------------------------------------------\r
// ERC721 Receiver\r
// ---------------------------------------------------------------------\r
/**\r
* Solo aceptamos el tokenId esperado, del contrato esperado, y únicamente\r
* cuando el depósito fue iniciado por lockAsset() (acceptingLock).\r
*/\r
function onERC721Received(\r
address /*operator*/,\r
address from,\r
uint256 _tokenId,\r
bytes calldata /*data*/\r
) external view override returns (bytes4) {\r
require(msg.sender == nftContract, "unexpected NFT");\r
require(_tokenId == tokenId, "unexpected tokenId");\r
require(acceptingLock, "use lockAsset()");\r
require(from == testator, "must come from testator");\r
return IERC721Receiver.onERC721Received.selector;\r
}\r
\r
// ---------------------------------------------------------------------\r
// Safety: reject ETH\r
// ---------------------------------------------------------------------\r
receive() external payable { revert("no ETH"); }\r
fallback() external payable { revert("no ETH"); }\r
}"
}
},
"settings": {
"optimizer": {
"enabled": true,
"runs": 200
},
"evmVersion": "paris",
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}
}}
Submitted on: 2025-10-09 09:10:13
Comments
Log in to comment.
No comments yet.