@keep-network/tbtc-v2 0.1.0 → 0.1.1-dev

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.
Files changed (296) hide show
  1. package/README.adoc +12 -0
  2. package/artifacts/.chainId +1 -1
  3. package/artifacts/Bank.json +807 -0
  4. package/artifacts/Bridge.json +2300 -0
  5. package/artifacts/Deposit.json +117 -0
  6. package/artifacts/DepositSweep.json +77 -0
  7. package/artifacts/EcdsaDkgValidator.json +532 -0
  8. package/artifacts/EcdsaInactivity.json +156 -0
  9. package/artifacts/EcdsaSortitionPool.json +1004 -0
  10. package/artifacts/Fraud.json +164 -0
  11. package/artifacts/KeepRegistry.json +99 -0
  12. package/artifacts/KeepStake.json +286 -0
  13. package/artifacts/KeepToken.json +711 -0
  14. package/artifacts/KeepTokenStaking.json +483 -0
  15. package/artifacts/MovingFunds.json +249 -0
  16. package/artifacts/NuCypherStakingEscrow.json +256 -0
  17. package/artifacts/NuCypherToken.json +711 -0
  18. package/artifacts/RandomBeaconStub.json +141 -0
  19. package/artifacts/Redemption.json +174 -0
  20. package/artifacts/ReimbursementPool.json +509 -0
  21. package/artifacts/Relay.json +123 -0
  22. package/artifacts/T.json +1148 -0
  23. package/artifacts/TBTC.json +36 -35
  24. package/artifacts/TBTCToken.json +738 -0
  25. package/artifacts/TBTCVault.json +691 -0
  26. package/artifacts/TokenStaking.json +2288 -0
  27. package/artifacts/TokenholderGovernor.json +1795 -0
  28. package/artifacts/TokenholderTimelock.json +1058 -0
  29. package/artifacts/VendingMachine.json +34 -33
  30. package/artifacts/VendingMachineKeep.json +400 -0
  31. package/artifacts/VendingMachineNuCypher.json +400 -0
  32. package/artifacts/WalletRegistry.json +1843 -0
  33. package/artifacts/WalletRegistryGovernance.json +2754 -0
  34. package/artifacts/Wallets.json +186 -0
  35. package/artifacts/solcInputs/5e62cff1ead0900b07facca4b559e818.json +314 -0
  36. package/build/contracts/GovernanceUtils.sol/GovernanceUtils.dbg.json +1 -1
  37. package/build/contracts/GovernanceUtils.sol/GovernanceUtils.json +2 -2
  38. package/build/contracts/bank/Bank.sol/Bank.dbg.json +4 -0
  39. package/build/contracts/bank/Bank.sol/Bank.json +542 -0
  40. package/build/contracts/bank/IReceiveBalanceApproval.sol/IReceiveBalanceApproval.dbg.json +4 -0
  41. package/build/contracts/bank/IReceiveBalanceApproval.sol/IReceiveBalanceApproval.json +34 -0
  42. package/build/contracts/bridge/BitcoinTx.sol/BitcoinTx.dbg.json +4 -0
  43. package/build/contracts/bridge/BitcoinTx.sol/BitcoinTx.json +10 -0
  44. package/build/contracts/bridge/Bridge.sol/Bridge.dbg.json +4 -0
  45. package/build/contracts/bridge/Bridge.sol/Bridge.json +2686 -0
  46. package/build/contracts/bridge/BridgeState.sol/BridgeState.dbg.json +4 -0
  47. package/build/contracts/bridge/BridgeState.sol/BridgeState.json +226 -0
  48. package/build/contracts/bridge/Deposit.sol/Deposit.dbg.json +4 -0
  49. package/build/contracts/bridge/Deposit.sol/Deposit.json +72 -0
  50. package/build/contracts/bridge/DepositSweep.sol/DepositSweep.dbg.json +4 -0
  51. package/build/contracts/bridge/DepositSweep.sol/DepositSweep.json +30 -0
  52. package/build/contracts/bridge/EcdsaLib.sol/EcdsaLib.dbg.json +4 -0
  53. package/build/contracts/bridge/EcdsaLib.sol/EcdsaLib.json +10 -0
  54. package/build/contracts/bridge/Fraud.sol/Fraud.dbg.json +4 -0
  55. package/build/contracts/bridge/Fraud.sol/Fraud.json +86 -0
  56. package/build/contracts/bridge/Heartbeat.sol/Heartbeat.dbg.json +4 -0
  57. package/build/contracts/bridge/Heartbeat.sol/Heartbeat.json +10 -0
  58. package/build/contracts/bridge/IRelay.sol/IRelay.dbg.json +4 -0
  59. package/build/contracts/bridge/IRelay.sol/IRelay.json +37 -0
  60. package/build/contracts/bridge/MovingFunds.sol/MovingFunds.dbg.json +4 -0
  61. package/build/contracts/bridge/MovingFunds.sol/MovingFunds.json +138 -0
  62. package/build/contracts/bridge/Redemption.sol/OutboundTx.dbg.json +4 -0
  63. package/build/contracts/bridge/Redemption.sol/OutboundTx.json +10 -0
  64. package/build/contracts/bridge/Redemption.sol/Redemption.dbg.json +4 -0
  65. package/build/contracts/bridge/Redemption.sol/Redemption.json +92 -0
  66. package/build/contracts/bridge/VendingMachine.sol/VendingMachine.dbg.json +1 -1
  67. package/build/contracts/bridge/VendingMachine.sol/VendingMachine.json +2 -2
  68. package/build/contracts/bridge/Wallets.sol/Wallets.dbg.json +4 -0
  69. package/build/contracts/bridge/Wallets.sol/Wallets.json +112 -0
  70. package/build/contracts/token/TBTC.sol/TBTC.dbg.json +1 -1
  71. package/build/contracts/token/TBTC.sol/TBTC.json +4 -4
  72. package/build/contracts/vault/DonationVault.sol/DonationVault.dbg.json +4 -0
  73. package/build/contracts/vault/DonationVault.sol/DonationVault.json +108 -0
  74. package/build/contracts/vault/IVault.sol/IVault.dbg.json +4 -0
  75. package/build/contracts/vault/IVault.sol/IVault.json +52 -0
  76. package/build/contracts/vault/TBTCVault.sol/TBTCVault.dbg.json +4 -0
  77. package/build/contracts/vault/TBTCVault.sol/TBTCVault.json +449 -0
  78. package/contracts/GovernanceUtils.sol +4 -4
  79. package/contracts/bank/Bank.sol +436 -0
  80. package/contracts/bank/IReceiveBalanceApproval.sol +45 -0
  81. package/contracts/bridge/BitcoinTx.sol +326 -0
  82. package/contracts/bridge/Bridge.sol +1793 -0
  83. package/contracts/bridge/BridgeState.sol +739 -0
  84. package/contracts/bridge/Deposit.sol +269 -0
  85. package/contracts/bridge/DepositSweep.sol +574 -0
  86. package/contracts/bridge/EcdsaLib.sol +45 -0
  87. package/contracts/bridge/Fraud.sol +579 -0
  88. package/contracts/bridge/Heartbeat.sol +112 -0
  89. package/contracts/bridge/IRelay.sol +28 -0
  90. package/contracts/bridge/MovingFunds.sol +1077 -0
  91. package/contracts/bridge/Redemption.sol +1020 -0
  92. package/contracts/bridge/VendingMachine.sol +2 -2
  93. package/contracts/bridge/Wallets.sol +719 -0
  94. package/contracts/hardhat-dependency-compiler/.hardhat-dependency-compiler +1 -0
  95. package/contracts/hardhat-dependency-compiler/@keep-network/ecdsa/contracts/WalletRegistry.sol +3 -0
  96. package/contracts/hardhat-dependency-compiler/@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol +3 -0
  97. package/contracts/hardhat-dependency-compiler/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol +3 -0
  98. package/contracts/token/TBTC.sol +1 -1
  99. package/contracts/vault/DonationVault.sol +125 -0
  100. package/contracts/vault/IVault.sol +44 -0
  101. package/contracts/vault/TBTCVault.sol +305 -0
  102. package/deploy/00_resolve_relay.ts +28 -0
  103. package/deploy/00_resolve_tbtc_v1_token.ts +1 -1
  104. package/deploy/01_deploy_tbtc_v2_token.ts +8 -1
  105. package/deploy/02_deploy_vending_machine.ts +7 -0
  106. package/deploy/{03_transfer_roles.ts → 03_transfer_vending_machine_roles.ts} +1 -1
  107. package/deploy/04_deploy_bank.ts +27 -0
  108. package/deploy/05_deploy_bridge.ts +80 -0
  109. package/deploy/06_deploy_tbtc_vault.ts +30 -0
  110. package/deploy/07_bank_update_bridge.ts +19 -0
  111. package/deploy/08_transfer_bank_ownership.ts +15 -0
  112. package/deploy/09_transfer_tbtc_vault_ownership.ts +15 -0
  113. package/deploy/10_transfer_bridge_governance.ts +20 -0
  114. package/deploy/11_initialize_wallet_owner.ts +18 -0
  115. package/deploy/11_transfer_proxy_admin_ownership.ts +30 -0
  116. package/deploy/12_deploy_proxy_admin_with_deputy.ts +33 -0
  117. package/export/deploy/00_resolve_relay.js +24 -0
  118. package/export/deploy/00_resolve_tbtc_v1_token.js +24 -0
  119. package/export/deploy/01_deploy_tbtc_v2_token.js +19 -0
  120. package/export/deploy/02_deploy_vending_machine.js +25 -0
  121. package/export/deploy/03_transfer_vending_machine_roles.js +19 -0
  122. package/export/deploy/04_deploy_bank.js +21 -0
  123. package/export/deploy/05_deploy_bridge.js +69 -0
  124. package/export/deploy/06_deploy_tbtc_vault.js +24 -0
  125. package/export/deploy/07_bank_update_bridge.js +13 -0
  126. package/export/deploy/08_transfer_bank_ownership.js +11 -0
  127. package/export/deploy/09_transfer_tbtc_vault_ownership.js +11 -0
  128. package/export/deploy/10_transfer_bridge_governance.js +11 -0
  129. package/export/deploy/11_initialize_wallet_owner.js +14 -0
  130. package/export/deploy/11_transfer_proxy_admin_ownership.js +23 -0
  131. package/export/deploy/12_deploy_proxy_admin_with_deputy.js +22 -0
  132. package/export/hardhat.config.js +169 -0
  133. package/export/test/bank/Bank.test.js +1012 -0
  134. package/export/test/bridge/Bridge.Deployment.test.js +76 -0
  135. package/export/test/bridge/Bridge.Deposit.test.js +1834 -0
  136. package/export/test/bridge/Bridge.Frauds.test.js +1349 -0
  137. package/export/test/bridge/Bridge.MovingFunds.test.js +2437 -0
  138. package/export/test/bridge/Bridge.Parameters.test.js +400 -0
  139. package/export/test/bridge/Bridge.Redemption.test.js +2523 -0
  140. package/export/test/bridge/Bridge.Vaults.test.js +74 -0
  141. package/export/test/bridge/Bridge.Wallets.test.js +1017 -0
  142. package/export/test/bridge/EcdsaLib.test.js +46 -0
  143. package/export/test/bridge/Heartbeat.test.js +77 -0
  144. package/export/test/bridge/VendingMachine.Upgrade.test.js +160 -0
  145. package/export/test/bridge/VendingMachine.test.js +762 -0
  146. package/export/test/data/deposit-sweep.js +655 -0
  147. package/export/test/data/ecdsa.js +18 -0
  148. package/export/test/data/fraud.js +158 -0
  149. package/export/test/data/moving-funds.js +815 -0
  150. package/export/test/data/redemption.js +1011 -0
  151. package/export/test/fixtures/bridge.js +54 -0
  152. package/export/test/fixtures/index.js +57 -0
  153. package/export/test/helpers/contract-test-helpers.js +18 -0
  154. package/export/test/integration/Slashing.test.js +279 -0
  155. package/export/test/integration/WalleCreation.test.js +66 -0
  156. package/export/test/integration/utils/ecdsa-wallet-registry.js +137 -0
  157. package/export/test/integration/utils/fixture.js +77 -0
  158. package/export/test/integration/utils/gas.js +36 -0
  159. package/export/test/integration/utils/random-beacon.js +26 -0
  160. package/export/test/integration/utils/staking.js +19 -0
  161. package/export/test/vault/DonationVault.test.js +202 -0
  162. package/export/test/vault/TBTCVault.Redemption.test.js +357 -0
  163. package/export/test/vault/TBTCVault.test.js +768 -0
  164. package/export/typechain/BTCUtils.js +2 -0
  165. package/export/typechain/Bank.js +2 -0
  166. package/export/typechain/BankStub.js +2 -0
  167. package/export/typechain/Bridge.js +2 -0
  168. package/export/typechain/BridgeState.js +2 -0
  169. package/export/typechain/BridgeStub.js +2 -0
  170. package/export/typechain/Deposit.js +2 -0
  171. package/export/typechain/DepositSweep.js +2 -0
  172. package/export/typechain/DonationVault.js +2 -0
  173. package/export/typechain/ERC165.js +2 -0
  174. package/export/typechain/ERC1967Proxy.js +2 -0
  175. package/export/typechain/ERC1967Upgrade.js +2 -0
  176. package/export/typechain/ERC20WithPermit.js +2 -0
  177. package/export/typechain/ERC721.js +2 -0
  178. package/export/typechain/EcdsaAuthorization.js +2 -0
  179. package/export/typechain/EcdsaDkg.js +2 -0
  180. package/export/typechain/EcdsaDkgValidator.js +2 -0
  181. package/export/typechain/EcdsaInactivity.js +2 -0
  182. package/export/typechain/Fraud.js +2 -0
  183. package/export/typechain/Governable.js +2 -0
  184. package/export/typechain/HeartbeatStub.js +2 -0
  185. package/export/typechain/IApplication.js +2 -0
  186. package/export/typechain/IApproveAndCall.js +2 -0
  187. package/export/typechain/IBeacon.js +2 -0
  188. package/export/typechain/IERC165.js +2 -0
  189. package/export/typechain/IERC1822Proxiable.js +2 -0
  190. package/export/typechain/IERC20.js +2 -0
  191. package/export/typechain/IERC20Metadata.js +2 -0
  192. package/export/typechain/IERC20WithPermit.js +2 -0
  193. package/export/typechain/IERC721.js +2 -0
  194. package/export/typechain/IERC721Metadata.js +2 -0
  195. package/export/typechain/IERC721Receiver.js +2 -0
  196. package/export/typechain/IRandomBeacon.js +2 -0
  197. package/export/typechain/IRandomBeaconConsumer.js +2 -0
  198. package/export/typechain/IReceiveApproval.js +2 -0
  199. package/export/typechain/IReceiveBalanceApproval.js +2 -0
  200. package/export/typechain/IRelay.js +2 -0
  201. package/export/typechain/IStaking.js +2 -0
  202. package/export/typechain/IVault.js +2 -0
  203. package/export/typechain/IWalletOwner.js +2 -0
  204. package/export/typechain/IWalletRegistry.js +2 -0
  205. package/export/typechain/Initializable.js +2 -0
  206. package/export/typechain/MisfundRecovery.js +2 -0
  207. package/export/typechain/MovingFunds.js +2 -0
  208. package/export/typechain/Ownable.js +2 -0
  209. package/export/typechain/Proxy.js +2 -0
  210. package/export/typechain/ProxyAdmin.js +2 -0
  211. package/export/typechain/ReceiveApprovalStub.js +2 -0
  212. package/export/typechain/Redemption.js +2 -0
  213. package/export/typechain/Reimbursable.js +2 -0
  214. package/export/typechain/ReimbursementPool.js +2 -0
  215. package/export/typechain/Rewards.js +2 -0
  216. package/export/typechain/SortitionPool.js +2 -0
  217. package/export/typechain/SortitionTree.js +2 -0
  218. package/export/typechain/TBTC.js +2 -0
  219. package/export/typechain/TBTCVault.js +2 -0
  220. package/export/typechain/TestERC20.js +2 -0
  221. package/export/typechain/TestERC721.js +2 -0
  222. package/export/typechain/TestEcdsaLib.js +2 -0
  223. package/export/typechain/TestRelay.js +2 -0
  224. package/export/typechain/TransparentUpgradeableProxy.js +2 -0
  225. package/export/typechain/VendingMachine.js +2 -0
  226. package/export/typechain/WalletRegistry.js +2 -0
  227. package/export/typechain/Wallets.js +2 -0
  228. package/export/typechain/common.js +2 -0
  229. package/export/typechain/factories/BTCUtils__factory.js +94 -0
  230. package/export/typechain/factories/BankStub__factory.js +586 -0
  231. package/export/typechain/factories/Bank__factory.js +573 -0
  232. package/export/typechain/factories/BridgeState__factory.js +257 -0
  233. package/export/typechain/factories/BridgeStub__factory.js +2912 -0
  234. package/export/typechain/factories/Bridge__factory.js +2526 -0
  235. package/export/typechain/factories/DepositSweep__factory.js +61 -0
  236. package/export/typechain/factories/Deposit__factory.js +103 -0
  237. package/export/typechain/factories/DonationVault__factory.js +139 -0
  238. package/export/typechain/factories/ERC165__factory.js +38 -0
  239. package/export/typechain/factories/ERC1967Proxy__factory.js +111 -0
  240. package/export/typechain/factories/ERC1967Upgrade__factory.js +64 -0
  241. package/export/typechain/factories/ERC20WithPermit__factory.js +524 -0
  242. package/export/typechain/factories/ERC721__factory.js +388 -0
  243. package/export/typechain/factories/EcdsaAuthorization__factory.js +211 -0
  244. package/export/typechain/factories/EcdsaDkgValidator__factory.js +441 -0
  245. package/export/typechain/factories/EcdsaDkg__factory.js +192 -0
  246. package/export/typechain/factories/EcdsaInactivity__factory.js +134 -0
  247. package/export/typechain/factories/Fraud__factory.js +117 -0
  248. package/export/typechain/factories/Governable__factory.js +64 -0
  249. package/export/typechain/factories/HeartbeatStub__factory.js +61 -0
  250. package/export/typechain/factories/IApplication__factory.js +152 -0
  251. package/export/typechain/factories/IApproveAndCall__factory.js +48 -0
  252. package/export/typechain/factories/IBeacon__factory.js +32 -0
  253. package/export/typechain/factories/IERC165__factory.js +38 -0
  254. package/export/typechain/factories/IERC1822Proxiable__factory.js +32 -0
  255. package/export/typechain/factories/IERC20Metadata__factory.js +241 -0
  256. package/export/typechain/factories/IERC20WithPermit__factory.js +389 -0
  257. package/export/typechain/factories/IERC20__factory.js +202 -0
  258. package/export/typechain/factories/IERC721Metadata__factory.js +349 -0
  259. package/export/typechain/factories/IERC721Receiver__factory.js +53 -0
  260. package/export/typechain/factories/IERC721__factory.js +304 -0
  261. package/export/typechain/factories/IRandomBeaconConsumer__factory.js +37 -0
  262. package/export/typechain/factories/IRandomBeacon__factory.js +32 -0
  263. package/export/typechain/factories/IReceiveApproval__factory.js +47 -0
  264. package/export/typechain/factories/IReceiveBalanceApproval__factory.js +42 -0
  265. package/export/typechain/factories/IRelay__factory.js +45 -0
  266. package/export/typechain/factories/IStaking__factory.js +722 -0
  267. package/export/typechain/factories/IVault__factory.js +60 -0
  268. package/export/typechain/factories/IWalletOwner__factory.js +65 -0
  269. package/export/typechain/factories/IWalletRegistry__factory.js +138 -0
  270. package/export/typechain/factories/Initializable__factory.js +32 -0
  271. package/export/typechain/factories/MisfundRecovery__factory.js +145 -0
  272. package/export/typechain/factories/MovingFunds__factory.js +169 -0
  273. package/export/typechain/factories/Ownable__factory.js +71 -0
  274. package/export/typechain/factories/ProxyAdmin__factory.js +191 -0
  275. package/export/typechain/factories/Proxy__factory.js +27 -0
  276. package/export/typechain/factories/ReceiveApprovalStub__factory.js +127 -0
  277. package/export/typechain/factories/Redemption__factory.js +123 -0
  278. package/export/typechain/factories/Reimbursable__factory.js +58 -0
  279. package/export/typechain/factories/ReimbursementPool__factory.js +350 -0
  280. package/export/typechain/factories/Rewards__factory.js +117 -0
  281. package/export/typechain/factories/SortitionPool__factory.js +610 -0
  282. package/export/typechain/factories/SortitionTree__factory.js +149 -0
  283. package/export/typechain/factories/TBTCVault__factory.js +480 -0
  284. package/export/typechain/factories/TBTC__factory.js +564 -0
  285. package/export/typechain/factories/TestERC20__factory.js +539 -0
  286. package/export/typechain/factories/TestERC721__factory.js +421 -0
  287. package/export/typechain/factories/TestEcdsaLib__factory.js +66 -0
  288. package/export/typechain/factories/TestRelay__factory.js +94 -0
  289. package/export/typechain/factories/TransparentUpgradeableProxy__factory.js +186 -0
  290. package/export/typechain/factories/VendingMachine__factory.js +549 -0
  291. package/export/typechain/factories/WalletRegistry__factory.js +1919 -0
  292. package/export/typechain/factories/Wallets__factory.js +143 -0
  293. package/export/typechain/index.js +132 -0
  294. package/export.json +15932 -503
  295. package/package.json +47 -26
  296. package/artifacts/solcInputs/7cc3eda3cb3ff2522d18b5e7b31ea228.json +0 -104
@@ -0,0 +1,80 @@
1
+ import { HardhatRuntimeEnvironment } from "hardhat/types"
2
+ import { DeployFunction } from "hardhat-deploy/types"
3
+
4
+ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
5
+ const { ethers, helpers, deployments, getNamedAccounts } = hre
6
+ const { deploy } = deployments
7
+ const { deployer, treasury } = await getNamedAccounts()
8
+
9
+ const Bank = await deployments.get("Bank")
10
+ const Relay = await deployments.get("Relay")
11
+
12
+ // TODO: Test for mainnet deployment that when `WalletRegistry` is provided
13
+ // in `external/mainnet/` directory it gets resolved correctly, and the deployment
14
+ // script from `@keep-network/ecdsa` is not invoked once again.
15
+ const WalletRegistry = await deployments.get("WalletRegistry")
16
+
17
+ // For local tests use `1`.
18
+ const txProofDifficultyFactor =
19
+ deployments.getNetworkName() === "hardhat" ? 1 : 6
20
+
21
+ const Deposit = await deploy("Deposit", { from: deployer, log: true })
22
+ const DepositSweep = await deploy("DepositSweep", {
23
+ from: deployer,
24
+ log: true,
25
+ })
26
+ const Redemption = await deploy("Redemption", { from: deployer, log: true })
27
+ const Wallets = await deploy("Wallets", {
28
+ contract: "contracts/bridge/Wallets.sol:Wallets",
29
+ from: deployer,
30
+ log: true,
31
+ })
32
+ const Fraud = await deploy("Fraud", { from: deployer, log: true })
33
+ const MovingFunds = await deploy("MovingFunds", {
34
+ from: deployer,
35
+ log: true,
36
+ })
37
+
38
+ const bridge = await helpers.upgrades.deployProxy("Bridge", {
39
+ contractName:
40
+ process.env.TEST_USE_STUBS_TBTC === "true" ? "BridgeStub" : undefined,
41
+ initializerArgs: [
42
+ Bank.address,
43
+ Relay.address,
44
+ treasury,
45
+ WalletRegistry.address,
46
+ txProofDifficultyFactor,
47
+ ],
48
+ factoryOpts: {
49
+ signer: await ethers.getSigner(deployer),
50
+ libraries: {
51
+ Deposit: Deposit.address,
52
+ DepositSweep: DepositSweep.address,
53
+ Redemption: Redemption.address,
54
+ Wallets: Wallets.address,
55
+ Fraud: Fraud.address,
56
+ MovingFunds: MovingFunds.address,
57
+ },
58
+ },
59
+ proxyOpts: {
60
+ kind: "transparent",
61
+ // Allow external libraries linking. We need to ensure manually that the
62
+ // external libraries we link are upgrade safe, as the OpenZeppelin plugin
63
+ // doesn't perform such a validation yet.
64
+ // See: https://docs.openzeppelin.com/upgrades-plugins/1.x/faq#why-cant-i-use-external-libraries
65
+ unsafeAllow: ["external-library-linking"],
66
+ },
67
+ })
68
+
69
+ if (hre.network.tags.tenderly) {
70
+ await hre.tenderly.verify({
71
+ name: "Bridge",
72
+ address: bridge.address,
73
+ })
74
+ }
75
+ }
76
+
77
+ export default func
78
+
79
+ func.tags = ["Bridge"]
80
+ func.dependencies = ["Bank", "Relay", "Treasury", "WalletRegistry"]
@@ -0,0 +1,30 @@
1
+ import { HardhatRuntimeEnvironment } from "hardhat/types"
2
+ import { DeployFunction } from "hardhat-deploy/types"
3
+
4
+ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
5
+ const { deployments, getNamedAccounts } = hre
6
+ const { deploy } = deployments
7
+ const { deployer } = await getNamedAccounts()
8
+
9
+ const Bank = await deployments.get("Bank")
10
+ const TBTC = await deployments.get("TBTC")
11
+
12
+ const TBTCVault = await deploy("TBTCVault", {
13
+ contract: "TBTCVault",
14
+ from: deployer,
15
+ args: [Bank.address, TBTC.address],
16
+ log: true,
17
+ })
18
+
19
+ if (hre.network.tags.tenderly) {
20
+ await hre.tenderly.verify({
21
+ name: "TBTCVault",
22
+ address: TBTCVault.address,
23
+ })
24
+ }
25
+ }
26
+
27
+ export default func
28
+
29
+ func.tags = ["TBTCVault"]
30
+ func.dependencies = ["Bank", "TBTC"]
@@ -0,0 +1,19 @@
1
+ import { HardhatRuntimeEnvironment } from "hardhat/types"
2
+ import { DeployFunction } from "hardhat-deploy/types"
3
+
4
+ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
5
+ const { getNamedAccounts, deployments } = hre
6
+ const { execute, log } = deployments
7
+ const { deployer } = await getNamedAccounts()
8
+
9
+ const Bridge = await deployments.get("Bridge")
10
+
11
+ log("updating Bridge in Bank")
12
+
13
+ await execute("Bank", { from: deployer }, "updateBridge", Bridge.address)
14
+ }
15
+
16
+ export default func
17
+
18
+ func.tags = ["BankUpdateBridge"]
19
+ func.dependencies = ["Bank", "Bridge"]
@@ -0,0 +1,15 @@
1
+ import { HardhatRuntimeEnvironment } from "hardhat/types"
2
+ import { DeployFunction } from "hardhat-deploy/types"
3
+
4
+ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
5
+ const { getNamedAccounts, helpers } = hre
6
+ const { deployer, governance } = await getNamedAccounts()
7
+
8
+ await helpers.ownable.transferOwnership("Bank", governance, deployer)
9
+ }
10
+
11
+ export default func
12
+
13
+ func.tags = ["TransferBankOwnership"]
14
+ func.dependencies = ["Bank"]
15
+ func.runAtTheEnd = true
@@ -0,0 +1,15 @@
1
+ import { HardhatRuntimeEnvironment } from "hardhat/types"
2
+ import { DeployFunction } from "hardhat-deploy/types"
3
+
4
+ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
5
+ const { getNamedAccounts, helpers } = hre
6
+ const { deployer, governance } = await getNamedAccounts()
7
+
8
+ await helpers.ownable.transferOwnership("TBTCVault", governance, deployer)
9
+ }
10
+
11
+ export default func
12
+
13
+ func.tags = ["TransferTBTCVaultOwnership"]
14
+ func.dependencies = ["TBTCVault"]
15
+ func.runAtTheEnd = true
@@ -0,0 +1,20 @@
1
+ import { HardhatRuntimeEnvironment } from "hardhat/types"
2
+ import { DeployFunction } from "hardhat-deploy/types"
3
+
4
+ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
5
+ const { getNamedAccounts, deployments } = hre
6
+ const { deployer, governance } = await getNamedAccounts()
7
+
8
+ await deployments.execute(
9
+ "Bridge",
10
+ { from: deployer },
11
+ "transferGovernance",
12
+ governance
13
+ )
14
+ }
15
+
16
+ export default func
17
+
18
+ func.tags = ["TransferBridgeGovernance"]
19
+ func.dependencies = ["Bridge"]
20
+ func.runAtTheEnd = true
@@ -0,0 +1,18 @@
1
+ import type { HardhatRuntimeEnvironment } from "hardhat/types"
2
+ import type { DeployFunction } from "hardhat-deploy/types"
3
+
4
+ import initializeWalletOwner from "@keep-network/ecdsa/export/tasks/initialize-wallet-owner"
5
+
6
+ const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
7
+ const Bridge = await hre.deployments.get("Bridge")
8
+
9
+ await initializeWalletOwner(hre, Bridge.address)
10
+ }
11
+
12
+ export default func
13
+
14
+ func.tags = ["InitializeWalletOwner"]
15
+ func.dependencies = ["Bridge"]
16
+
17
+ func.skip = async (hre: HardhatRuntimeEnvironment): Promise<boolean> =>
18
+ hre.network.name === "mainnet"
@@ -0,0 +1,30 @@
1
+ import type { HardhatRuntimeEnvironment } from "hardhat/types"
2
+ import type { DeployFunction } from "hardhat-deploy/types"
3
+
4
+ const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
5
+ const { helpers, upgrades, deployments } = hre
6
+ const { esdm, deployer } = await helpers.signers.getNamedSigners()
7
+ const { log } = deployments
8
+
9
+ // TODO: Once a DAO is established we want to switch to ProxyAdminWithDeputy and
10
+ // use the DAO as the proxy admin owner and ESDM as the deputy. Until then we
11
+ // use ESDM as the owner of ProxyAdmin contract.
12
+ const newProxyAdminOwner = esdm.address
13
+
14
+ const proxyAdmin = await upgrades.admin.getInstance()
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
+ }
25
+ }
26
+
27
+ export default func
28
+
29
+ func.tags = ["TransferProxyAdminOwnership"]
30
+ func.dependencies = ["Bridge"]
@@ -0,0 +1,33 @@
1
+ import type { HardhatRuntimeEnvironment } from "hardhat/types"
2
+ import type { DeployFunction } from "hardhat-deploy/types"
3
+
4
+ const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
5
+ const { ethers, getNamedAccounts, upgrades, deployments } = hre
6
+ const { deployer, dao, esdm } = await getNamedAccounts()
7
+
8
+ const BridgeProxyAdminWithDeputy = await deployments.deploy(
9
+ "BridgeProxyAdminWithDeputy",
10
+ {
11
+ contract: "ProxyAdminWithDeputy",
12
+ from: deployer,
13
+ args: [dao, esdm],
14
+ log: true,
15
+ }
16
+ )
17
+
18
+ const Bridge = await deployments.get("Bridge")
19
+
20
+ const proxyAdmin = await upgrades.admin.getInstance()
21
+
22
+ await proxyAdmin
23
+ .connect(await ethers.getSigner(esdm))
24
+ .changeProxyAdmin(Bridge.address, BridgeProxyAdminWithDeputy.address)
25
+ }
26
+
27
+ export default func
28
+
29
+ func.tags = ["BridgeProxyAdminWithDeputy"]
30
+ func.dependencies = ["Bridge"]
31
+
32
+ // TODO: For now we skip this script as DAO is not yet established.
33
+ func.skip = async () => true
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const func = async function (hre) {
4
+ const { getNamedAccounts, deployments, helpers } = hre;
5
+ const { log } = deployments;
6
+ const { deployer } = await getNamedAccounts();
7
+ const Relay = await deployments.getOrNull("Relay");
8
+ if (Relay && helpers.address.isValid(Relay.address)) {
9
+ log(`using external Relay at ${Relay.address}`);
10
+ }
11
+ else if (hre.network.name !== "hardhat") {
12
+ throw new Error("deployed Relay contract not found");
13
+ }
14
+ else {
15
+ log("deploying Relay stub");
16
+ await deployments.deploy("Relay", {
17
+ contract: "TestRelay",
18
+ from: deployer,
19
+ log: true,
20
+ });
21
+ }
22
+ };
23
+ exports.default = func;
24
+ func.tags = ["Relay"];
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const func = async function (hre) {
4
+ const { getNamedAccounts, deployments, helpers } = hre;
5
+ const { log } = deployments;
6
+ const { deployer } = await getNamedAccounts();
7
+ const TBTCToken = await deployments.getOrNull("TBTCToken");
8
+ if (TBTCToken && helpers.address.isValid(TBTCToken.address)) {
9
+ log(`using external TBTCToken at ${TBTCToken.address}`);
10
+ }
11
+ else if (hre.network.name !== "hardhat") {
12
+ throw new Error("deployed TBTCToken contract not found");
13
+ }
14
+ else {
15
+ log("deploying TBTCToken stub");
16
+ await deployments.deploy("TBTCToken", {
17
+ contract: "TestERC20",
18
+ from: deployer,
19
+ log: true,
20
+ });
21
+ }
22
+ };
23
+ exports.default = func;
24
+ func.tags = ["TBTCToken"];
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const func = async function (hre) {
4
+ const { deployments, getNamedAccounts } = hre;
5
+ const { deploy } = deployments;
6
+ const { deployer } = await getNamedAccounts();
7
+ const TBTC = await deploy("TBTC", {
8
+ from: deployer,
9
+ log: true,
10
+ });
11
+ if (hre.network.tags.tenderly) {
12
+ await hre.tenderly.verify({
13
+ name: "TBTC",
14
+ address: TBTC.address,
15
+ });
16
+ }
17
+ };
18
+ exports.default = func;
19
+ func.tags = ["TBTC"];
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const func = async function (hre) {
4
+ const { deployments, helpers, getNamedAccounts } = hre;
5
+ const { deploy } = deployments;
6
+ const { deployer } = await getNamedAccounts();
7
+ const TBTCToken = await deployments.get("TBTCToken");
8
+ const TBTC = await deployments.get("TBTC"); // tBTC v2
9
+ const unmintFee = 0;
10
+ const VendingMachine = await deploy("VendingMachine", {
11
+ from: deployer,
12
+ args: [TBTCToken.address, TBTC.address, unmintFee],
13
+ log: true,
14
+ });
15
+ await helpers.ownable.transferOwnership("TBTC", VendingMachine.address, deployer);
16
+ if (hre.network.tags.tenderly) {
17
+ await hre.tenderly.verify({
18
+ name: "VendingMachine",
19
+ address: VendingMachine.address,
20
+ });
21
+ }
22
+ };
23
+ exports.default = func;
24
+ func.tags = ["VendingMachine"];
25
+ func.dependencies = ["TBTCToken", "TBTC"];
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const func = async function (hre) {
4
+ const { getNamedAccounts, helpers, deployments } = hre;
5
+ const { execute, log } = deployments;
6
+ const { deployer, keepTechnicalWalletTeam, keepCommunityMultiSig } = await getNamedAccounts();
7
+ log(`transferring vendingMachineUpgradeInitiator role to ${keepTechnicalWalletTeam}`);
8
+ await execute("VendingMachine", { from: deployer }, "transferVendingMachineUpgradeInitiatorRole", keepTechnicalWalletTeam);
9
+ log(`transferring unmintFeeUpdateInitiator role to ${keepTechnicalWalletTeam}`);
10
+ await execute("VendingMachine", { from: deployer }, "transferUnmintFeeUpdateInitiatorRole", keepTechnicalWalletTeam);
11
+ await helpers.ownable.transferOwnership("VendingMachine", keepCommunityMultiSig, deployer);
12
+ };
13
+ exports.default = func;
14
+ func.tags = ["TransferVendingMachineRoles"];
15
+ func.dependencies = ["TBTC", "VendingMachine"];
16
+ func.runAtTheEnd = true;
17
+ func.skip = async function (hre) {
18
+ return hre.network.name !== "mainnet";
19
+ };
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const func = async function (hre) {
4
+ const { deployments, getNamedAccounts } = hre;
5
+ const { deploy } = deployments;
6
+ const { deployer } = await getNamedAccounts();
7
+ const Bank = await deploy("Bank", {
8
+ contract: process.env.TEST_USE_STUBS_TBTC === "true" ? "BankStub" : undefined,
9
+ from: deployer,
10
+ args: [],
11
+ log: true,
12
+ });
13
+ if (hre.network.tags.tenderly) {
14
+ await hre.tenderly.verify({
15
+ name: "Bank",
16
+ address: Bank.address,
17
+ });
18
+ }
19
+ };
20
+ exports.default = func;
21
+ func.tags = ["Bank"];
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const func = async function (hre) {
4
+ const { ethers, helpers, deployments, getNamedAccounts } = hre;
5
+ const { deploy } = deployments;
6
+ const { deployer, treasury } = await getNamedAccounts();
7
+ const Bank = await deployments.get("Bank");
8
+ const Relay = await deployments.get("Relay");
9
+ // TODO: Test for mainnet deployment that when `WalletRegistry` is provided
10
+ // in `external/mainnet/` directory it gets resolved correctly, and the deployment
11
+ // script from `@keep-network/ecdsa` is not invoked once again.
12
+ const WalletRegistry = await deployments.get("WalletRegistry");
13
+ // For local tests use `1`.
14
+ const txProofDifficultyFactor = deployments.getNetworkName() === "hardhat" ? 1 : 6;
15
+ const Deposit = await deploy("Deposit", { from: deployer, log: true });
16
+ const DepositSweep = await deploy("DepositSweep", {
17
+ from: deployer,
18
+ log: true,
19
+ });
20
+ const Redemption = await deploy("Redemption", { from: deployer, log: true });
21
+ const Wallets = await deploy("Wallets", {
22
+ contract: "contracts/bridge/Wallets.sol:Wallets",
23
+ from: deployer,
24
+ log: true,
25
+ });
26
+ const Fraud = await deploy("Fraud", { from: deployer, log: true });
27
+ const MovingFunds = await deploy("MovingFunds", {
28
+ from: deployer,
29
+ log: true,
30
+ });
31
+ const bridge = await helpers.upgrades.deployProxy("Bridge", {
32
+ contractName: process.env.TEST_USE_STUBS_TBTC === "true" ? "BridgeStub" : undefined,
33
+ initializerArgs: [
34
+ Bank.address,
35
+ Relay.address,
36
+ treasury,
37
+ WalletRegistry.address,
38
+ txProofDifficultyFactor,
39
+ ],
40
+ factoryOpts: {
41
+ signer: await ethers.getSigner(deployer),
42
+ libraries: {
43
+ Deposit: Deposit.address,
44
+ DepositSweep: DepositSweep.address,
45
+ Redemption: Redemption.address,
46
+ Wallets: Wallets.address,
47
+ Fraud: Fraud.address,
48
+ MovingFunds: MovingFunds.address,
49
+ },
50
+ },
51
+ proxyOpts: {
52
+ kind: "transparent",
53
+ // Allow external libraries linking. We need to ensure manually that the
54
+ // external libraries we link are upgrade safe, as the OpenZeppelin plugin
55
+ // doesn't perform such a validation yet.
56
+ // See: https://docs.openzeppelin.com/upgrades-plugins/1.x/faq#why-cant-i-use-external-libraries
57
+ unsafeAllow: ["external-library-linking"],
58
+ },
59
+ });
60
+ if (hre.network.tags.tenderly) {
61
+ await hre.tenderly.verify({
62
+ name: "Bridge",
63
+ address: bridge.address,
64
+ });
65
+ }
66
+ };
67
+ exports.default = func;
68
+ func.tags = ["Bridge"];
69
+ func.dependencies = ["Bank", "Relay", "Treasury", "WalletRegistry"];
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const func = async function (hre) {
4
+ const { deployments, getNamedAccounts } = hre;
5
+ const { deploy } = deployments;
6
+ const { deployer } = await getNamedAccounts();
7
+ const Bank = await deployments.get("Bank");
8
+ const TBTC = await deployments.get("TBTC");
9
+ const TBTCVault = await deploy("TBTCVault", {
10
+ contract: "TBTCVault",
11
+ from: deployer,
12
+ args: [Bank.address, TBTC.address],
13
+ log: true,
14
+ });
15
+ if (hre.network.tags.tenderly) {
16
+ await hre.tenderly.verify({
17
+ name: "TBTCVault",
18
+ address: TBTCVault.address,
19
+ });
20
+ }
21
+ };
22
+ exports.default = func;
23
+ func.tags = ["TBTCVault"];
24
+ func.dependencies = ["Bank", "TBTC"];
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const func = async function (hre) {
4
+ const { getNamedAccounts, deployments } = hre;
5
+ const { execute, log } = deployments;
6
+ const { deployer } = await getNamedAccounts();
7
+ const Bridge = await deployments.get("Bridge");
8
+ log("updating Bridge in Bank");
9
+ await execute("Bank", { from: deployer }, "updateBridge", Bridge.address);
10
+ };
11
+ exports.default = func;
12
+ func.tags = ["BankUpdateBridge"];
13
+ func.dependencies = ["Bank", "Bridge"];
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const func = async function (hre) {
4
+ const { getNamedAccounts, helpers } = hre;
5
+ const { deployer, governance } = await getNamedAccounts();
6
+ await helpers.ownable.transferOwnership("Bank", governance, deployer);
7
+ };
8
+ exports.default = func;
9
+ func.tags = ["TransferBankOwnership"];
10
+ func.dependencies = ["Bank"];
11
+ func.runAtTheEnd = true;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const func = async function (hre) {
4
+ const { getNamedAccounts, helpers } = hre;
5
+ const { deployer, governance } = await getNamedAccounts();
6
+ await helpers.ownable.transferOwnership("TBTCVault", governance, deployer);
7
+ };
8
+ exports.default = func;
9
+ func.tags = ["TransferTBTCVaultOwnership"];
10
+ func.dependencies = ["TBTCVault"];
11
+ func.runAtTheEnd = true;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const func = async function (hre) {
4
+ const { getNamedAccounts, deployments } = hre;
5
+ const { deployer, governance } = await getNamedAccounts();
6
+ await deployments.execute("Bridge", { from: deployer }, "transferGovernance", governance);
7
+ };
8
+ exports.default = func;
9
+ func.tags = ["TransferBridgeGovernance"];
10
+ func.dependencies = ["Bridge"];
11
+ func.runAtTheEnd = true;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const initialize_wallet_owner_1 = __importDefault(require("@keep-network/ecdsa/export/tasks/initialize-wallet-owner"));
7
+ const func = async (hre) => {
8
+ const Bridge = await hre.deployments.get("Bridge");
9
+ await (0, initialize_wallet_owner_1.default)(hre, Bridge.address);
10
+ };
11
+ exports.default = func;
12
+ func.tags = ["InitializeWalletOwner"];
13
+ func.dependencies = ["Bridge"];
14
+ func.skip = async (hre) => hre.network.name === "mainnet";
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const func = async (hre) => {
4
+ const { helpers, upgrades, deployments } = hre;
5
+ const { esdm, deployer } = await helpers.signers.getNamedSigners();
6
+ const { log } = deployments;
7
+ // TODO: Once a DAO is established we want to switch to ProxyAdminWithDeputy and
8
+ // use the DAO as the proxy admin owner and ESDM as the deputy. Until then we
9
+ // use ESDM as the owner of ProxyAdmin contract.
10
+ const newProxyAdminOwner = esdm.address;
11
+ const proxyAdmin = await upgrades.admin.getInstance();
12
+ const currentOwner = await proxyAdmin.owner();
13
+ // The `@openzeppelin/hardhat-upgrades` plugin deploys a single ProxyAdmin
14
+ // per network. We don't want to transfer the ownership if the owner is already
15
+ // set to the desired address.
16
+ if (!helpers.address.equal(currentOwner, newProxyAdminOwner)) {
17
+ log(`transferring ownership of ProxyAdmin to ${newProxyAdminOwner}`);
18
+ await proxyAdmin.connect(deployer).transferOwnership(newProxyAdminOwner);
19
+ }
20
+ };
21
+ exports.default = func;
22
+ func.tags = ["TransferProxyAdminOwnership"];
23
+ func.dependencies = ["Bridge"];
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const func = async (hre) => {
4
+ const { ethers, getNamedAccounts, upgrades, deployments } = hre;
5
+ const { deployer, dao, esdm } = await getNamedAccounts();
6
+ const BridgeProxyAdminWithDeputy = await deployments.deploy("BridgeProxyAdminWithDeputy", {
7
+ contract: "ProxyAdminWithDeputy",
8
+ from: deployer,
9
+ args: [dao, esdm],
10
+ log: true,
11
+ });
12
+ const Bridge = await deployments.get("Bridge");
13
+ const proxyAdmin = await upgrades.admin.getInstance();
14
+ await proxyAdmin
15
+ .connect(await ethers.getSigner(esdm))
16
+ .changeProxyAdmin(Bridge.address, BridgeProxyAdminWithDeputy.address);
17
+ };
18
+ exports.default = func;
19
+ func.tags = ["BridgeProxyAdminWithDeputy"];
20
+ func.dependencies = ["Bridge"];
21
+ // TODO: For now we skip this script as DAO is not yet established.
22
+ func.skip = async () => true;