Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(world): add Balance table and BalanceTransferSystem #1425

Merged
merged 11 commits into from
Sep 12, 2023
Prev Previous commit
Next Next commit
use call{value: amount}('') instead of transfer
  • Loading branch information
alvrs committed Sep 10, 2023
commit ef1c7843c000a8522878277614b522f3a00e553a
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@
pragma solidity >=0.8.0;

import { System } from "../../../System.sol";
import { revertWithBytes } from "../../../revertWithBytes.sol";
import { ResourceSelector } from "../../../ResourceSelector.sol";
import { AccessControl } from "../../../AccessControl.sol";
import { IWorldErrors } from "../../../interfaces/IWorldErrors.sol";
@@ -44,6 +45,9 @@ contract BalanceTransferSystem is System, IWorldErrors {

// Update the balances
Balances.set(fromNamespace, balance - amount);
payable(toAddress).transfer(amount);

// Transfer the balance to the given address, revert on failure
(bool success, bytes memory data) = payable(toAddress).call{ value: amount }("");
if (!success) revertWithBytes(data);
}
}