Skip to content

Commit

Permalink
add a few more depositAndRegister endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
0age committed Oct 28, 2024
1 parent eec2243 commit 3381898
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
18 changes: 18 additions & 0 deletions src/TheCompact.sol
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,14 @@ contract TheCompact is ITheCompact, ERC6909, Tstorish {
_deposit(msg.sender, id, msg.value);
}

function depositAndRegister(address allocator, bytes32 claimHash, bytes32 typehash) external payable returns (uint256 id) {
id = address(0).toIdIfRegistered(Scope.Multichain, ResetPeriod.TenMinutes, allocator);

_deposit(msg.sender, id, msg.value);

_register(msg.sender, claimHash, typehash);
}

function deposit(address token, address allocator, uint256 amount) external returns (uint256 id) {
_setTstorish(_REENTRANCY_GUARD_SLOT, 1);
id = token.excludingNative().toIdIfRegistered(Scope.Multichain, ResetPeriod.TenMinutes, allocator);
Expand All @@ -255,6 +263,16 @@ contract TheCompact is ITheCompact, ERC6909, Tstorish {
_clearTstorish(_REENTRANCY_GUARD_SLOT);
}

function depositAndRegister(address token, address allocator, uint256 amount, bytes32 claimHash, bytes32 typehash) external returns (uint256 id) {
_setTstorish(_REENTRANCY_GUARD_SLOT, 1);
id = token.excludingNative().toIdIfRegistered(Scope.Multichain, ResetPeriod.TenMinutes, allocator);

_transferAndDeposit(token, msg.sender, id, amount);

_register(msg.sender, claimHash, typehash);
_clearTstorish(_REENTRANCY_GUARD_SLOT);
}

function deposit(address allocator, ResetPeriod resetPeriod, Scope scope, address recipient) external payable returns (uint256 id) {
id = address(0).toIdIfRegistered(scope, resetPeriod, allocator);

Expand Down
6 changes: 6 additions & 0 deletions src/interfaces/ITheCompact.sol
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,20 @@ interface ITheCompact {

function deposit(address allocator) external payable returns (uint256 id);

function depositAndRegister(address allocator, bytes32 claimHash, bytes32 typehash) external payable returns (uint256 id);

function deposit(address token, address allocator, uint256 amount) external returns (uint256 id);

function depositAndRegister(address token, address allocator, uint256 amount, bytes32 claimHash, bytes32 typehash) external returns (uint256 id);

function deposit(address allocator, ResetPeriod resetPeriod, Scope scope, address recipient) external payable returns (uint256 id);

function deposit(address token, address allocator, ResetPeriod resetPeriod, Scope scope, uint256 amount, address recipient) external returns (uint256 id);

function deposit(uint256[2][] calldata idsAndAmounts, address recipient) external payable returns (bool);

function depositAndRegister(uint256[2][] calldata idsAndAmounts, bytes32[2][] calldata claimHashesAndTypehashes) external payable returns (bool);

function deposit(
address token,
uint256 amount,
Expand Down
2 changes: 1 addition & 1 deletion src/test/CalldataDebugger.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ contract CalldataDebugger {
fallback() external payable {
revert Debug(msg.data);
}
}
}

0 comments on commit 3381898

Please sign in to comment.