Skip to content

Commit

Permalink
Small fix
Browse files Browse the repository at this point in the history
  • Loading branch information
AndriianChestnykh committed Feb 18, 2025
1 parent df9732b commit cee07b4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion contracts/payment/VCPayment.sol
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,10 @@ contract VCPayment is Ownable2StepUpgradeable, ReentrancyGuardUpgradeable {
uint256 issuerId,
uint256 schemaHash,
address withdrawAddress
) external ownerOrIssuer(issuerId, schemaHash) validAddress(withdrawAddress) nonReentrant {
) external onlyOwner validAddress(withdrawAddress) nonReentrant {
VCPaymentStorage storage $ = _getVCPaymentStorage();
PaymentData storage payData = $.paymentData[keccak256(abi.encode(issuerId, schemaHash))];

uint256 issuerBalance = $.issuerAddressBalance[payData.withdrawAddress];
$.issuerAddressBalance[payData.withdrawAddress] = 0;
$.issuerAddressBalance[withdrawAddress] += issuerBalance;
Expand Down
10 changes: 5 additions & 5 deletions test/payment/vc-payment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,14 @@ describe("VC Payment Contract", () => {

// this should not override the withdrawal balance of issuer 1
await payment
.connect(issuer2Signer)
.connect(owner)
.updateWithdrawAddress(issuerId2.bigInt(), schemaHash3.bigInt(), issuer1Signer.address);

expect(await payment.connect(issuer1Signer).getMyBalance()).to.be.eq(9500);
expect(await payment.connect(issuer2Signer).getMyBalance()).to.be.eq(0);

await payment
.connect(issuer1Signer)
.connect(owner)
.updateWithdrawAddress(issuerId1.bigInt(), schemaHash1.bigInt(), issuer2Signer.address);

expect(await payment.connect(issuer1Signer).getMyBalance()).to.be.eq(0);
Expand Down Expand Up @@ -228,11 +228,11 @@ describe("VC Payment Contract", () => {
.connect(userSigner)
.updateWithdrawAddress(issuerId1.bigInt(), schemaHash1.bigInt(), issuer2Signer.address),
)
.to.be.revertedWithCustomError(payment, "WrongOwnerOrIssuer")
.withArgs(owner.address, issuer1Signer.address, userSigner.address);
.to.be.revertedWithCustomError(payment, "OwnableUnauthorizedAccount")
.withArgs(userSigner.address);

await payment
.connect(issuer1Signer)
.connect(owner)
.updateWithdrawAddress(issuerId1.bigInt(), schemaHash1.bigInt(), issuer2Signer.address);
const paymentData = await payment
.connect(issuer2Signer)
Expand Down

0 comments on commit cee07b4

Please sign in to comment.