DeployNFTBridge.s.sol 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. // SPDX-License-Identifier: UNLICENSED
  2. pragma solidity ^0.8.4;
  3. import {NFTBridgeImplementation} from "../contracts/nft/NFTBridgeImplementation.sol";
  4. import {NFTBridgeSetup} from "../contracts/nft/NFTBridgeSetup.sol";
  5. import {NFTImplementation} from "../contracts/nft/token/NFTImplementation.sol";
  6. import {NFTBridgeEntrypoint} from "../contracts/nft/NFTBridgeEntrypoint.sol";
  7. import "forge-std/Script.sol";
  8. contract DeployNFTBridge is Script {
  9. NFTImplementation nftImpl;
  10. NFTBridgeSetup nftBridgeSetup;
  11. NFTBridgeImplementation nftBridgeImpl;
  12. function dryRun(
  13. uint16 chainId,
  14. uint16 governanceChainId,
  15. bytes32 governanceContract,
  16. uint8 finality,
  17. uint256 evmChainId,
  18. address wormhole
  19. ) public {
  20. _deploy(
  21. chainId,
  22. governanceChainId,
  23. governanceContract,
  24. finality,
  25. evmChainId,
  26. wormhole
  27. );
  28. }
  29. function run(
  30. uint16 chainId,
  31. uint16 governanceChainId,
  32. bytes32 governanceContract,
  33. uint8 finality,
  34. uint256 evmChainId,
  35. address wormhole
  36. )
  37. public
  38. returns (
  39. address deployedAddress,
  40. address nftImplementationAddress,
  41. address setupAddress,
  42. address implementationAddress
  43. )
  44. {
  45. vm.startBroadcast();
  46. (
  47. deployedAddress,
  48. nftImplementationAddress,
  49. setupAddress,
  50. implementationAddress
  51. ) = _deploy(
  52. chainId,
  53. governanceChainId,
  54. governanceContract,
  55. finality,
  56. evmChainId,
  57. wormhole
  58. );
  59. vm.stopBroadcast();
  60. }
  61. function _deploy(
  62. uint16 chainId,
  63. uint16 governanceChainId,
  64. bytes32 governanceContract,
  65. uint8 finality,
  66. uint256 evmChainId,
  67. address wormhole
  68. )
  69. internal
  70. returns (
  71. address deployedAddress,
  72. address nftImplementationAddress,
  73. address setupAddress,
  74. address implementationAddress
  75. )
  76. {
  77. nftImpl = new NFTImplementation();
  78. nftBridgeSetup = new NFTBridgeSetup();
  79. nftBridgeImpl = new NFTBridgeImplementation();
  80. NFTBridgeEntrypoint nftBridge = new NFTBridgeEntrypoint(
  81. address(nftBridgeSetup),
  82. abi.encodeWithSignature(
  83. "setup(address,uint16,address,uint16,bytes32,address,uint8,uint256)",
  84. address(nftBridgeImpl),
  85. chainId,
  86. wormhole,
  87. governanceChainId,
  88. governanceContract,
  89. address(nftImpl),
  90. finality,
  91. evmChainId
  92. )
  93. );
  94. return (
  95. address(nftBridge),
  96. address(nftImpl),
  97. address(nftBridgeSetup),
  98. address(nftBridgeImpl)
  99. );
  100. }
  101. }