@keep-network/tbtc-v2 0.1.1-dev.77 → 0.1.1-dev.78
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/artifacts/Bank.json +16 -16
- package/artifacts/Bridge.json +5 -5
- package/artifacts/Deposit.json +7 -7
- package/artifacts/DepositSweep.json +7 -7
- package/artifacts/EcdsaDkgValidator.json +1 -1
- package/artifacts/EcdsaInactivity.json +1 -1
- package/artifacts/EcdsaSortitionPool.json +2 -2
- package/artifacts/Fraud.json +7 -7
- package/artifacts/KeepRegistry.json +1 -1
- package/artifacts/KeepStake.json +2 -2
- package/artifacts/KeepToken.json +2 -2
- package/artifacts/KeepTokenStaking.json +1 -1
- package/artifacts/MovingFunds.json +7 -7
- package/artifacts/NuCypherStakingEscrow.json +1 -1
- package/artifacts/NuCypherToken.json +2 -2
- package/artifacts/RandomBeaconStub.json +1 -1
- package/artifacts/Redemption.json +7 -7
- package/artifacts/ReimbursementPool.json +2 -2
- package/artifacts/Relay.json +9 -9
- package/artifacts/T.json +2 -2
- package/artifacts/TBTC.json +3 -3
- package/artifacts/TBTCToken.json +3 -3
- package/artifacts/TokenStaking.json +1 -1
- package/artifacts/TokenholderGovernor.json +9 -9
- package/artifacts/TokenholderTimelock.json +8 -8
- package/artifacts/VendingMachine.json +10 -10
- package/artifacts/VendingMachineKeep.json +1 -1
- package/artifacts/VendingMachineNuCypher.json +1 -1
- package/artifacts/WalletRegistry.json +5 -5
- package/artifacts/WalletRegistryGovernance.json +2 -2
- package/artifacts/Wallets.json +7 -7
- package/artifacts/solcInputs/{490ffccc38e413544104a916bd6aa53c.json → 53b3428138f3e1a8f29707c3a3799af0.json} +5 -2
- package/build/contracts/GovernanceUtils.sol/GovernanceUtils.dbg.json +1 -1
- package/build/contracts/bank/Bank.sol/Bank.dbg.json +1 -1
- package/build/contracts/bank/Bank.sol/Bank.json +3 -3
- package/build/contracts/bank/IReceiveBalanceApproval.sol/IReceiveBalanceApproval.dbg.json +4 -0
- package/build/contracts/bank/IReceiveBalanceApproval.sol/IReceiveBalanceApproval.json +29 -0
- package/build/contracts/bridge/BitcoinTx.sol/BitcoinTx.dbg.json +1 -1
- package/build/contracts/bridge/BitcoinTx.sol/BitcoinTx.json +2 -2
- package/build/contracts/bridge/Bridge.sol/Bridge.dbg.json +1 -1
- package/build/contracts/bridge/Bridge.sol/Bridge.json +2 -2
- package/build/contracts/bridge/BridgeState.sol/BridgeState.dbg.json +1 -1
- package/build/contracts/bridge/BridgeState.sol/BridgeState.json +2 -2
- package/build/contracts/bridge/Deposit.sol/Deposit.dbg.json +1 -1
- package/build/contracts/bridge/Deposit.sol/Deposit.json +2 -2
- package/build/contracts/bridge/DepositSweep.sol/DepositSweep.dbg.json +1 -1
- package/build/contracts/bridge/DepositSweep.sol/DepositSweep.json +2 -2
- package/build/contracts/bridge/EcdsaLib.sol/EcdsaLib.dbg.json +1 -1
- package/build/contracts/bridge/Fraud.sol/Fraud.dbg.json +1 -1
- package/build/contracts/bridge/Fraud.sol/Fraud.json +2 -2
- package/build/contracts/bridge/Heartbeat.sol/Heartbeat.dbg.json +1 -1
- package/build/contracts/bridge/IRelay.sol/IRelay.dbg.json +1 -1
- package/build/contracts/bridge/MovingFunds.sol/MovingFunds.dbg.json +1 -1
- package/build/contracts/bridge/MovingFunds.sol/MovingFunds.json +2 -2
- package/build/contracts/bridge/Redemption.sol/OutboundTx.dbg.json +1 -1
- package/build/contracts/bridge/Redemption.sol/OutboundTx.json +2 -2
- package/build/contracts/bridge/Redemption.sol/Redemption.dbg.json +1 -1
- package/build/contracts/bridge/Redemption.sol/Redemption.json +2 -2
- package/build/contracts/bridge/VendingMachine.sol/VendingMachine.dbg.json +1 -1
- package/build/contracts/bridge/Wallets.sol/Wallets.dbg.json +1 -1
- package/build/contracts/bridge/Wallets.sol/Wallets.json +2 -2
- package/build/contracts/token/TBTC.sol/TBTC.dbg.json +1 -1
- package/build/contracts/vault/DonationVault.sol/DonationVault.dbg.json +1 -1
- package/build/contracts/vault/DonationVault.sol/DonationVault.json +2 -2
- package/build/contracts/vault/IVault.sol/IVault.dbg.json +1 -1
- package/build/contracts/vault/TBTCVault.sol/TBTCVault.dbg.json +1 -1
- package/build/contracts/vault/TBTCVault.sol/TBTCVault.json +2 -2
- package/contracts/bank/Bank.sol +13 -9
- package/contracts/bank/IReceiveBalanceApproval.sol +40 -0
- package/contracts/vault/IVault.sol +3 -19
- package/export.json +1 -1
- package/package.json +1 -1
package/contracts/bank/Bank.sol
CHANGED
|
@@ -17,6 +17,7 @@ pragma solidity ^0.8.9;
|
|
|
17
17
|
|
|
18
18
|
import "@openzeppelin/contracts/access/Ownable.sol";
|
|
19
19
|
|
|
20
|
+
import "./IReceiveBalanceApproval.sol";
|
|
20
21
|
import "../vault/IVault.sol";
|
|
21
22
|
|
|
22
23
|
/// @title Bitcoin Bank
|
|
@@ -114,19 +115,22 @@ contract Bank is Ownable {
|
|
|
114
115
|
_approveBalance(msg.sender, spender, amount);
|
|
115
116
|
}
|
|
116
117
|
|
|
117
|
-
/// @notice Sets `amount` as
|
|
118
|
-
/// the caller's balance and calls the
|
|
118
|
+
/// @notice Sets the `amount` as an allowance of a smart contract `spender`
|
|
119
|
+
/// over the caller's balance and calls the `spender` via
|
|
119
120
|
/// `receiveBalanceApproval`.
|
|
120
|
-
/// @dev If the `amount` is set to `type(uint256).max
|
|
121
|
-
/// `
|
|
122
|
-
///
|
|
123
|
-
/// allowance with this function brings the risk that
|
|
121
|
+
/// @dev If the `amount` is set to `type(uint256).max`, the potential
|
|
122
|
+
/// `transferBalanceFrom` executed in `receiveBalanceApproval` of
|
|
123
|
+
/// `spender` will not reduce an allowance. Beware that changing an
|
|
124
|
+
/// allowance with this function brings the risk that `spender` may use
|
|
124
125
|
/// both the old and the new allowance by unfortunate transaction
|
|
125
126
|
/// ordering. Please use `increaseBalanceAllowance` and
|
|
126
127
|
/// `decreaseBalanceAllowance` to eliminate the risk.
|
|
127
|
-
function approveBalanceAndCall(address
|
|
128
|
-
_approveBalance(msg.sender,
|
|
129
|
-
|
|
128
|
+
function approveBalanceAndCall(address spender, uint256 amount) external {
|
|
129
|
+
_approveBalance(msg.sender, spender, amount);
|
|
130
|
+
IReceiveBalanceApproval(spender).receiveBalanceApproval(
|
|
131
|
+
msg.sender,
|
|
132
|
+
amount
|
|
133
|
+
);
|
|
130
134
|
}
|
|
131
135
|
|
|
132
136
|
/// @notice Atomically increases the balance allowance granted to `spender`
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
|
|
3
|
+
// ██████████████ ▐████▌ ██████████████
|
|
4
|
+
// ██████████████ ▐████▌ ██████████████
|
|
5
|
+
// ▐████▌ ▐████▌
|
|
6
|
+
// ▐████▌ ▐████▌
|
|
7
|
+
// ██████████████ ▐████▌ ██████████████
|
|
8
|
+
// ██████████████ ▐████▌ ██████████████
|
|
9
|
+
// ▐████▌ ▐████▌
|
|
10
|
+
// ▐████▌ ▐████▌
|
|
11
|
+
// ▐████▌ ▐████▌
|
|
12
|
+
// ▐████▌ ▐████▌
|
|
13
|
+
// ▐████▌ ▐████▌
|
|
14
|
+
// ▐████▌ ▐████▌
|
|
15
|
+
|
|
16
|
+
pragma solidity ^0.8.9;
|
|
17
|
+
|
|
18
|
+
/// @title IReceiveBalanceApproval
|
|
19
|
+
/// @notice `IReceiveBalanceApproval` is an interface for a smart contract
|
|
20
|
+
/// consuming Bank balances approved to them in the same transaction by
|
|
21
|
+
/// other contracts or externally owned accounts (EOA).
|
|
22
|
+
interface IReceiveBalanceApproval {
|
|
23
|
+
/// @notice Called by the Bank in `approveBalanceAndCall` function after
|
|
24
|
+
/// the balance `owner` approved `amount` of their balance in the
|
|
25
|
+
/// Bank for the contract. This way, the depositor can approve
|
|
26
|
+
/// balance and call the contract to use the approved balance in
|
|
27
|
+
/// a single transaction.
|
|
28
|
+
/// @param owner Address of the Bank balance owner who approved their
|
|
29
|
+
/// balance to be used by the contract.
|
|
30
|
+
/// @param amount The amount of the Bank balance approved by the owner
|
|
31
|
+
/// to be used by the contract.
|
|
32
|
+
// @dev The implementation must ensure this function can only be called
|
|
33
|
+
/// by the Bank. The Bank does _not_ guarantee that the `amount`
|
|
34
|
+
/// approved by the `owner` currently exists on their balance. That is,
|
|
35
|
+
/// the `owner` could approve more balance than they currently have.
|
|
36
|
+
/// This works the same as `Bank.approve` function. The contract must
|
|
37
|
+
/// ensure the actual balance is checked before performing any action
|
|
38
|
+
/// based on it.
|
|
39
|
+
function receiveBalanceApproval(address owner, uint256 amount) external;
|
|
40
|
+
}
|
|
@@ -15,28 +15,12 @@
|
|
|
15
15
|
|
|
16
16
|
pragma solidity ^0.8.9;
|
|
17
17
|
|
|
18
|
+
import "../bank/IReceiveBalanceApproval.sol";
|
|
19
|
+
|
|
18
20
|
/// @title Bank Vault interface
|
|
19
21
|
/// @notice `IVault` is an interface for a smart contract consuming Bank
|
|
20
22
|
/// balances of other contracts or externally owned accounts (EOA).
|
|
21
|
-
interface IVault {
|
|
22
|
-
/// @notice Called by the Bank in `approveBalanceAndCall` function after
|
|
23
|
-
/// the balance `owner` approved `amount` of their balance in the
|
|
24
|
-
/// Bank for the vault. This way, the depositor can approve balance
|
|
25
|
-
/// and call the vault to use the approved balance in a single
|
|
26
|
-
/// transaction.
|
|
27
|
-
/// @param owner Address of the Bank balance owner who approved their
|
|
28
|
-
/// balance to be used by the vault.
|
|
29
|
-
/// @param amount The amount of the Bank balance approved by the owner
|
|
30
|
-
/// to be used by the vault.
|
|
31
|
-
// @dev The implementation must ensure this function can only be called
|
|
32
|
-
/// by the Bank. The Bank does _not_ guarantee that the `amount`
|
|
33
|
-
/// approved by the `owner` currently exists on their balance. That is,
|
|
34
|
-
/// the `owner` could approve more balance than they currently have.
|
|
35
|
-
/// This works the same as `Bank.approve` function. The vault must
|
|
36
|
-
/// ensure the actual balance is checked before performing any action
|
|
37
|
-
/// based on it.
|
|
38
|
-
function receiveBalanceApproval(address owner, uint256 amount) external;
|
|
39
|
-
|
|
23
|
+
interface IVault is IReceiveBalanceApproval {
|
|
40
24
|
/// @notice Called by the Bank in `increaseBalanceAndCall` function after
|
|
41
25
|
/// increasing the balance in the Bank for the vault. It happens in
|
|
42
26
|
/// the same transaction in which deposits were swept by the Bridge.
|
package/export.json
CHANGED
|
@@ -13370,7 +13370,7 @@
|
|
|
13370
13370
|
"inputs": [
|
|
13371
13371
|
{
|
|
13372
13372
|
"internalType": "address",
|
|
13373
|
-
"name": "
|
|
13373
|
+
"name": "spender",
|
|
13374
13374
|
"type": "address"
|
|
13375
13375
|
},
|
|
13376
13376
|
{
|