mirror of
https://github.com/logos-storage/logos-storage-contracts-eth.git
synced 2026-01-06 15:23:11 +00:00
vault: only allow account holder to withdraw for itself
This commit is contained in:
parent
95a698c574
commit
6db1a5fb3a
@ -224,6 +224,7 @@ contract Vault is VaultBase, Pausable, Ownable {
|
||||
AccountId account
|
||||
) public {
|
||||
(address holder, ) = Accounts.decodeId(account);
|
||||
require(msg.sender == holder, VaultOnlyAccountHolder());
|
||||
_withdraw(controller, fund, account);
|
||||
}
|
||||
|
||||
@ -234,4 +235,6 @@ contract Vault is VaultBase, Pausable, Ownable {
|
||||
function unpause() public onlyOwner {
|
||||
_unpause();
|
||||
}
|
||||
|
||||
error VaultOnlyAccountHolder();
|
||||
}
|
||||
|
||||
@ -772,7 +772,7 @@ describe("Vault", function () {
|
||||
expect(after - before).to.equal(amount)
|
||||
})
|
||||
|
||||
it("allows recipient to withdraw for itself", async function () {
|
||||
it("allows account holder to withdraw for itself", async function () {
|
||||
await expire()
|
||||
const before = await token.balanceOf(holder.address)
|
||||
await vault
|
||||
@ -782,6 +782,15 @@ describe("Vault", function () {
|
||||
expect(after - before).to.equal(amount)
|
||||
})
|
||||
|
||||
it("does not allow anyone else to withdraw for the account holder", async function () {
|
||||
await expire()
|
||||
await expect(
|
||||
vault
|
||||
.connect(holder2)
|
||||
.withdrawByRecipient(controller.address, fund, account1)
|
||||
).to.be.revertedWith("OnlyAccountHolder")
|
||||
})
|
||||
|
||||
it("empties the balance when withdrawing", async function () {
|
||||
await expire()
|
||||
await vault.withdraw(fund, account1)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user