@keep-network/tbtc-v2 0.1.1-dev.75 → 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 +23 -23
- package/artifacts/Bridge.json +78 -3
- package/artifacts/Deposit.json +10 -10
- package/artifacts/DepositSweep.json +10 -10
- package/artifacts/EcdsaDkgValidator.json +16 -17
- package/artifacts/EcdsaInactivity.json +6 -6
- package/artifacts/EcdsaSortitionPool.json +1004 -0
- package/artifacts/Fraud.json +10 -10
- 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 +10 -10
- package/artifacts/NuCypherStakingEscrow.json +1 -1
- package/artifacts/NuCypherToken.json +2 -2
- package/artifacts/RandomBeaconStub.json +6 -6
- package/artifacts/Redemption.json +10 -10
- package/artifacts/ReimbursementPool.json +24 -24
- package/artifacts/Relay.json +12 -12
- package/artifacts/T.json +2 -2
- package/artifacts/TBTC.json +19 -19
- package/artifacts/TBTCToken.json +19 -19
- package/artifacts/TokenStaking.json +1 -1
- package/artifacts/TokenholderGovernor.json +9 -9
- package/artifacts/TokenholderTimelock.json +8 -8
- package/artifacts/VendingMachine.json +24 -24
- package/artifacts/VendingMachineKeep.json +1 -1
- package/artifacts/VendingMachineNuCypher.json +1 -1
- package/artifacts/WalletRegistry.json +893 -1167
- package/artifacts/WalletRegistryGovernance.json +2754 -0
- package/artifacts/Wallets.json +10 -10
- package/artifacts/solcInputs/{49c80d59bf0ae61f27a8bb5db19af68a.json → 53b3428138f3e1a8f29707c3a3799af0.json} +111 -72
- 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/hardhat-dependency-compiler/@keep-network/ecdsa/contracts/WalletRegistry.sol +3 -0
- package/contracts/vault/IVault.sol +3 -19
- package/deploy/05_deploy_bridge.ts +5 -1
- package/deploy/09_transfer_proxy_admin_ownership.ts +15 -8
- package/export.json +2524 -3068
- package/package.json +3 -3
- package/artifacts/DefaultProxyAdmin.json +0 -259
- package/artifacts/SortitionPool.json +0 -1005
- package/artifacts/WalletRegistry_Implementation.json +0 -2824
- package/artifacts/WalletRegistry_Proxy.json +0 -259
- package/artifacts/solcInputs/1635d55d57a0a2552952c0d22586ed23.json +0 -56
- package/deploy/00_resolve_wallet_registry.ts +0 -83
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.
|
|
@@ -24,7 +24,11 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
|
|
|
24
24
|
log: true,
|
|
25
25
|
})
|
|
26
26
|
const Redemption = await deploy("Redemption", { from: deployer, log: true })
|
|
27
|
-
const Wallets = await deploy("Wallets", {
|
|
27
|
+
const Wallets = await deploy("Wallets", {
|
|
28
|
+
contract: "contracts/bridge/Wallets.sol:Wallets",
|
|
29
|
+
from: deployer,
|
|
30
|
+
log: true,
|
|
31
|
+
})
|
|
28
32
|
const Fraud = await deploy("Fraud", { from: deployer, log: true })
|
|
29
33
|
const MovingFunds = await deploy("MovingFunds", {
|
|
30
34
|
from: deployer,
|
|
@@ -2,19 +2,26 @@ import type { HardhatRuntimeEnvironment } from "hardhat/types"
|
|
|
2
2
|
import type { DeployFunction } from "hardhat-deploy/types"
|
|
3
3
|
|
|
4
4
|
const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
|
|
5
|
-
const {
|
|
6
|
-
const { esdm } = await
|
|
7
|
-
const {
|
|
5
|
+
const { helpers, upgrades, deployments } = hre
|
|
6
|
+
const { esdm, deployer } = await helpers.signers.getNamedSigners()
|
|
7
|
+
const { log } = deployments
|
|
8
8
|
|
|
9
9
|
// TODO: Once a DAO is established we want to switch to ProxyAdminWithDeputy and
|
|
10
10
|
// use the DAO as the proxy admin owner and ESDM as the deputy. Until then we
|
|
11
|
-
// use
|
|
12
|
-
const newProxyAdminOwner = esdm
|
|
13
|
-
|
|
14
|
-
deployments.log(`transferring ProxyAdmin ownership to ${newProxyAdminOwner}`)
|
|
11
|
+
// use ESDM as the owner of ProxyAdmin contract.
|
|
12
|
+
const newProxyAdminOwner = esdm.address
|
|
15
13
|
|
|
16
14
|
const proxyAdmin = await upgrades.admin.getInstance()
|
|
17
|
-
|
|
15
|
+
|
|
16
|
+
const currentOwner = await proxyAdmin.owner()
|
|
17
|
+
|
|
18
|
+
// The `@openzeppelin/hardhat-upgrades` plugin deploys a single ProxyAdmin
|
|
19
|
+
// per network. We don't want to transfer the ownership if the owner is already
|
|
20
|
+
// set to the desired address.
|
|
21
|
+
if (!helpers.address.equal(currentOwner, newProxyAdminOwner)) {
|
|
22
|
+
log(`transferring ownership of ProxyAdmin to ${newProxyAdminOwner}`)
|
|
23
|
+
await proxyAdmin.connect(deployer).transferOwnership(newProxyAdminOwner)
|
|
24
|
+
}
|
|
18
25
|
}
|
|
19
26
|
|
|
20
27
|
export default func
|