Verified contractExactMIT
WalletBindingRegistry
Address0x147e07d6c69a79053fc8a59dba58e6befeb5e493
- Balance
0 ETH
- Transactions
1
- Compiler
solc 0.8.20
- Same code
Only this contract
Details
- Compiler
- solc 0.8.20+commit.a1b79de6
- Language
- solidity
- Optimization
- Yes, 200 runs
- EVM version
- shanghai
- License
- MIT
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,244,152
- Creation transaction
- 0xab5ddc6b99…8a384143f3
2 files
src/WalletBindingRegistry.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import { Initializable } from "@openzeppelin/proxy/utils/Initializable.sol";
/**
* @notice One-time bindings between portfolio wallets and their cross-chain recipients.
*
* For Solana, Circle CCTP mint recipients are 32-byte public keys. In
* practice this is typically the destination SPL token account (e.g. the
* USDC associated token account) rather than the owner wallet address.
*
* This binding is intentionally one-way / immutable. There is no update
* path — by design, to prevent backend-controlled updates from becoming
* a fund-exfiltration vector if Ground's signing keys are compromised.
* If a binding must change, deploy a new registry and migrate users via
* explicit consent. Stellar bindings store Circle's versioned forwarder
* hook containing the destination G address.
*/
contract WalletBindingRegistry is Initializable {
error AlreadyBound(address wallet);
error InvalidRecipient();
error InvalidStellarHook();
mapping(address => bytes32) private solanaMintRecipients;
mapping(address => bytes) private stellarForwarderHooks;
mapping(address => address) private tempoRecipients;
mapping(address => address) private ethereumRecipients;
event SolanaMintRecipientBound(address indexed wallet, bytes32 indexed solanaMintRecipient);
event StellarForwarderHookBound(address indexed wallet, bytes32 indexed hookDataHash);
event TempoRecipientBound(address indexed wallet, address indexed tempoRecipient);
event EthereumRecipientBound(address indexed wallet, address indexed ethereumRecipient);
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
_disableInitializers();
}
function initialize() external initializer { }
function getSolanaMintRecipient(address wallet) external view returns (bytes32) {
return solanaMintRecipients[wallet];
}
function isBound(address wallet) external view returns (bool) {
return solanaMintRecipients[wallet] != bytes32(0);
}
function getStellarForwarderHook(address wallet) external view returns (bytes memory) {
return stellarForwarderHooks[wallet];
}
function getTempoRecipient(address wallet) external view returns (address) {
return tempoRecipients[wallet];
}
function getEthereumRecipient(address wallet) external view returns (address) {
return ethereumRecipients[wallet];
}
function setInitialEthereumRecipient(address recipient) external {
if (recipient == address(0)) revert InvalidRecipient();
if (ethereumRecipients[msg.sender] != address(0)) revert AlreadyBound(msg.sender);
ethereumRecipients[msg.sender] = recipient;
emit EthereumRecipientBound(msg.sender, recipient);
}
/**
* @notice Bind the caller to a Solana mint recipient. One-time.
* Reverts with AlreadyBound(msg.sender) on second call.
*/
function setInitialSolanaMintRecipient(bytes32 solanaMintRecipient) external {
if (solanaMintRecipient == bytes32(0)) revert InvalidRecipient();
if (solanaMintRecipients[msg.sender] != bytes32(0)) revert AlreadyBound(msg.sender);
solanaMintRecipients[msg.sender] = solanaMintRecipient;
emit SolanaMintRecipientBound(msg.sender, solanaMintRecipient);
}
function setInitialStellarForwarderHook(bytes calldata hookData) external {
if (stellarForwarderHooks[msg.sender].length != 0) revert AlreadyBound(msg.sender);
if (!_isValidStellarHook(hookData)) revert InvalidStellarHook();
stellarForwarderHooks[msg.sender] = hookData;
emit StellarForwarderHookBound(msg.sender, keccak256(hookData));
}
function setInitialTempoRecipient(address tempoRecipient) external {
if (tempoRecipient == address(0)) revert InvalidRecipient();
if (tempoRecipients[msg.sender] != address(0)) revert AlreadyBound(msg.sender);
tempoRecipients[msg.sender] = tempoRecipient;
emit TempoRecipientBound(msg.sender, tempoRecipient);
}
function _isValidStellarHook(bytes calldata hookData) private pure returns (bool) {
if (hookData.length != 88) return false;
for (uint256 i = 0; i < 24; i++) {
if (hookData[i] != 0) return false;
}
if (
hookData[24] != 0 || hookData[25] != 0 || hookData[26] != 0 || hookData[27] != 0
|| hookData[28] != 0 || hookData[29] != 0 || hookData[30] != 0 || uint8(hookData[31]) != 56
) return false;
bytes memory decoded = new bytes(35);
uint256 accumulator;
uint256 bits;
uint256 outputIndex;
for (uint256 i = 32; i < 88; i++) {
uint8 character = uint8(hookData[i]);
uint8 value;
if (character >= 65 && character <= 90) {
value = character - 65;
} else if (character >= 50 && character <= 55) {
value = character - 24;
} else {
return false;
}
accumulator = (accumulator << 5) | value;
bits += 5;
while (bits >= 8) {
bits -= 8;
decoded[outputIndex++] = bytes1(uint8(accumulator >> bits));
accumulator &= (uint256(1) << bits) - 1;
}
}
if (outputIndex != 35 || bits != 0 || uint8(decoded[0]) != 48) return false;
uint16 checksum;
for (uint256 i = 0; i < 33; i++) {
checksum ^= uint16(uint8(decoded[i])) << 8;
for (uint256 bit = 0; bit < 8; bit++) {
checksum = (checksum & 0x8000) != 0 ? (checksum << 1) ^ 0x1021 : checksum << 1;
}
}
return uint8(decoded[33]) == uint8(checksum) && uint8(decoded[34]) == uint8(checksum >> 8);
}
}
lib/openzeppelin-contracts/contracts/proxy/utils/Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.20;
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```solidity
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
*
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Storage of the initializable contract.
*
* It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions
* when using with upgradeable contracts.
*
* @custom:storage-location erc7201:openzeppelin.storage.Initializable
*/
struct InitializableStorage {
/**
* @dev Indicates that the contract has been initialized.
*/
uint64 _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool _initializing;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;
/**
* @dev The contract is already initialized.
*/
error InvalidInitialization();
/**
* @dev The contract is not initializing.
*/
error NotInitializing();
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint64 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any
* number of times. This behavior in the constructor can be useful during testing and is not expected to be used in
* production.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
// Cache values to avoid duplicated sloads
bool isTopLevelCall = !$._initializing;
uint64 initialized = $._initialized;
// Allowed calls:
// - initialSetup: the contract is not in the initializing state and no previous version was
// initialized
// - construction: the contract is initialized at version 1 (no reininitialization) and the
// current contract is just being deployed
bool initialSetup = initialized == 0 && isTopLevelCall;
bool construction = initialized == 1 && address(this).code.length == 0;
if (!initialSetup && !construction) {
revert InvalidInitialization();
}
$._initialized = 1;
if (isTopLevelCall) {
$._initializing = true;
}
_;
if (isTopLevelCall) {
$._initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint64 version) {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing || $._initialized >= version) {
revert InvalidInitialization();
}
$._initialized = version;
$._initializing = true;
_;
$._initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
_checkInitializing();
_;
}
/**
* @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.
*/
function _checkInitializing() internal view virtual {
if (!_isInitializing()) {
revert NotInitializing();
}
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing) {
revert InvalidInitialization();
}
if ($._initialized != type(uint64).max) {
$._initialized = type(uint64).max;
emit Initialized(type(uint64).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint64) {
return _getInitializableStorage()._initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _getInitializableStorage()._initializing;
}
/**
* @dev Returns a pointer to the storage namespace.
*/
// solhint-disable-next-line var-name-mixedcase
function _getInitializableStorage() private pure returns (InitializableStorage storage $) {
assembly {
$.slot := INITIALIZABLE_STORAGE
}
}
}
Compiler settingsShow
{
"viaIR": false,
"metadata": {
"appendCBOR": true,
"bytecodeHash": "ipfs",
"useLiteralContent": false
},
"optimizer": {
"runs": 200,
"enabled": true
},
"evmVersion": "shanghai",
"remappings": [
"@openzeppelin/=lib/openzeppelin-contracts/contracts/",
"forge-std/=lib/openzeppelin-contracts/lib/forge-std/src/",
"ds-test/=lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
"erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/"
]
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.