似乎是在Registry會同步創立一個Anchor,藉由獨立Anchor 合約來處理所有外部與其他合約的呼叫(不確定以前遇過甚麼問題所以需要這樣獨立處理)
此合約確保與外部地址的安全且經過授權的互動,增強了個人資料的功能,並使操作的執行得以控制。該合約利用Registry合約進行所有權驗證和訪問控制。
藉由變數registry 與Registry 互作reference, 由profileId來驗證
外部呼叫藉由registry.isOwnerOfProfile(profileId, msg.sender)
來驗證是否
參數 _target目標合約 , _value 要給目標合約的$ , _data 要給目標合約帶入的資料
回傳也是 bytes形式
function execute(address _target, uint256 _value, bytes memory _data) external returns (bytes memory) {
// Check if the caller is the owner of the profile and revert if not
if (!registry.isOwnerOfProfile(profileId, msg.sender)) revert UNAUTHORIZED();
// Check if the target address is the zero address and revert if it is
if (_target == address(0)) revert CALL_FAILED();
// Call the target address and return the data
(bool success, bytes memory data) = _target.call{value: _value}(_data);
// Check if the call was successful and revert if not
if (!success) revert CALL_FAILED();
return data;
}
/// @notice This contract should be able to receive native token
receive() external payable {}