Skip to content

Commit

Permalink
add withdraw to frame lazy claim because we have to remove excess funds
Browse files Browse the repository at this point in the history
  • Loading branch information
wwhchung committed Jan 31, 2024
1 parent 7d0d644 commit 0c972f1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/manifold/contracts/frameclaims/FrameLazyClaim.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ abstract contract FrameLazyClaim is IFrameLazyClaim, AdminControl {
_transferOwnership(initialOwner);
}


/**
* See {IFrameLazyClaim-withdraw}.
*/
function withdraw(address payable receiver, uint256 amount) external override adminRequired {
(bool sent, ) = receiver.call{value: amount}("");
if (!sent) revert FailedToTransfer();
}

/**
* See {IFrameLazyClaim-setSigner}.
*/
Expand Down
6 changes: 6 additions & 0 deletions packages/manifold/contracts/frameclaims/IFrameLazyClaim.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ interface IFrameLazyClaim {
enum StorageProtocol { INVALID, NONE, ARWEAVE, IPFS }

error InvalidSignature();
error FailedToTransfer();

event FrameClaimInitialized(address indexed creatorContract, uint256 indexed instanceId, address initializer);
event FrameClaimUpdated(address indexed creatorContract, uint256 indexed instanceId);
Expand All @@ -21,6 +22,11 @@ interface IFrameLazyClaim {
uint256 amount;
}

/**
* @notice Withdraw funds
*/
function withdraw(address payable receiver, uint256 amount) external;

/**
* @notice Set the signing address
* @param signer the signer address
Expand Down
12 changes: 12 additions & 0 deletions packages/manifold/test/frameclaims/ERC1155FrameLazyClaim.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,16 @@ contract ERC1155FrameLazyClaimTest is Test {
vm.deal(creator, 10 ether);
vm.deal(other, 10 ether);
vm.deal(signer, 10 ether);
vm.deal(address(example), 10 ether);
}

function testAccess() public {
vm.startPrank(other);

// Must be admin
vm.expectRevert();
example.withdraw(payable(other), 20);

// Must be admin
vm.expectRevert();
example.setSigner(other);
Expand Down Expand Up @@ -76,6 +82,12 @@ contract ERC1155FrameLazyClaimTest is Test {
vm.stopPrank();
}

function testWithdraw() public {
vm.startPrank(owner);
example.withdraw(payable(owner), 1 ether);
vm.stopPrank();
}

function testinitializeClaimSanitization() public {
vm.startPrank(creator);

Expand Down

0 comments on commit 0c972f1

Please sign in to comment.