From 91003e51c4ed86d9c4921d877f1a5fa2c2b5c8dd Mon Sep 17 00:00:00 2001 From: princetonbishop Date: Thu, 2 Jan 2025 15:39:39 +0100 Subject: [PATCH] update scripts --- .../templegold/TempleTeleporterTestnet.sol | 114 ++++++++++++++++++ protocol/hardhat.config.ts | 1 + ...090F9655a0B0A32cEE0Da5ae45E93EAB4C6d149.js | 3 + ...92aA9BfDcA5540406E211950C226C8E0cd5047F.js | 7 ++ ...ae6318e34bb97ae3755AFcE75559452aA223A5D.js | 12 ++ ...8c5E61b1B3731A1f379E8770861164d23118cdc.js | 12 ++ ...e9162230D9e637218D74C7f41f62ef2385fEe64.js | 7 ++ ...bc7cf85dd0AB91Aa2671400E86ebf3AaC6dc658.js | 7 ++ .../cartio/templegold/02-temple-gold.ts | 8 +- .../cartio/templegold/03-temple-teleporter.ts | 6 +- .../cartio/templegold/04-temple-gold-admin.ts | 7 +- .../deploys/cartio/templegold/999-ops.ts | 35 ++++++ .../templegold/999-transfer-ownership.ts | 43 ------- protocol/scripts/deploys/helpers.ts | 1 + .../mainnet/templegold/contract-addresses.ts | 39 +++++- ...455A2bDbE76d36c835824D9A41E6842216d6c36.js | 7 ++ ...ef2c51FeB8539b692596f6b6b2867Ae7154ceAe.js | 7 ++ .../templegold/03-temple-teleporter.ts | 9 +- .../deploys/sepolia/templegold/99-ops.ts | 43 +++++++ 19 files changed, 302 insertions(+), 66 deletions(-) create mode 100644 protocol/contracts/fakes/templegold/TempleTeleporterTestnet.sol create mode 100644 protocol/scripts/deploys/cartio/deploymentArgs/0x0090F9655a0B0A32cEE0Da5ae45E93EAB4C6d149.js create mode 100644 protocol/scripts/deploys/cartio/deploymentArgs/0x192aA9BfDcA5540406E211950C226C8E0cd5047F.js create mode 100644 protocol/scripts/deploys/cartio/deploymentArgs/0x2ae6318e34bb97ae3755AFcE75559452aA223A5D.js create mode 100644 protocol/scripts/deploys/cartio/deploymentArgs/0x98c5E61b1B3731A1f379E8770861164d23118cdc.js create mode 100644 protocol/scripts/deploys/cartio/deploymentArgs/0xBe9162230D9e637218D74C7f41f62ef2385fEe64.js create mode 100644 protocol/scripts/deploys/cartio/deploymentArgs/0xcbc7cf85dd0AB91Aa2671400E86ebf3AaC6dc658.js create mode 100644 protocol/scripts/deploys/cartio/templegold/999-ops.ts delete mode 100644 protocol/scripts/deploys/cartio/templegold/999-transfer-ownership.ts create mode 100644 protocol/scripts/deploys/sepolia/deploymentArgs/0x7455A2bDbE76d36c835824D9A41E6842216d6c36.js create mode 100644 protocol/scripts/deploys/sepolia/deploymentArgs/0x8ef2c51FeB8539b692596f6b6b2867Ae7154ceAe.js create mode 100644 protocol/scripts/deploys/sepolia/templegold/99-ops.ts diff --git a/protocol/contracts/fakes/templegold/TempleTeleporterTestnet.sol b/protocol/contracts/fakes/templegold/TempleTeleporterTestnet.sol new file mode 100644 index 000000000..5276af4c4 --- /dev/null +++ b/protocol/contracts/fakes/templegold/TempleTeleporterTestnet.sol @@ -0,0 +1,114 @@ +pragma solidity ^0.8.20; +// SPDX-License-Identifier: AGPL-3.0-or-later +// Temple (fakes/templegold/TempleTeleporterTestnet.sol) + + +import { CommonEventsAndErrors } from "contracts/common/CommonEventsAndErrors.sol"; +import { FakeERC20 } from "contracts/fakes/FakeERC20.sol"; +import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; +import { OApp } from "@layerzerolabs/lz-evm-oapp-v2/contracts/oapp/OApp.sol"; +import { MessagingReceipt, MessagingFee } from "@layerzerolabs/lz-evm-oapp-v2/contracts/oapp/OAppSender.sol"; +import { Origin } from "@layerzerolabs/lz-evm-oapp-v2/contracts/oapp/interfaces/IOAppReceiver.sol"; +import { OFTMsgCodec } from "@layerzerolabs/lz-evm-oapp-v2/contracts/oft/libs/OFTMsgCodec.sol"; + +/** + * @title Temple Teleporter for testnet + * @notice Temple Teleporter transfers Temple token cross-chain with layer zero integration. + * The only change in contract is moving from templeToken.burnFrom() to templeToken.burn() to go with testnet temple token + * which is not burnable. Interface has changed too from ITempleERC20Token to FakeERC20. + * ITempleTeleporter interface is removed. + */ +contract TempleTeleporterTestnet is OApp { + using OFTMsgCodec for address; + + /// @notice Temple token + FakeERC20 public immutable temple; + + event TempleTeleported(uint32 dstEid, address indexed sender, address indexed recipient, uint256 amount); + + constructor( + address _executor, + address _temple, + address _endpoint + ) Ownable(_executor) OApp(_endpoint, _executor){ + temple = FakeERC20(_temple); + } + + /** + * @notice Teleport temple tokens cross chain + * Enough msg.value needs to be sent through to cover completing execution and the transfer by endpoint and on the destination chain. + * This value can be estimated via the `quote()` function. + * @dev Temple tokens are burned from source chain and minted on destination chain + * @param dstEid Destination chain id + * @param to Recipient + * @param amount Amount of tokens + * @param options LZ extra options + */ + function teleport( + uint32 dstEid, + address to, + uint256 amount, + bytes calldata options + ) external payable returns(MessagingReceipt memory receipt) { + if (amount == 0) { revert CommonEventsAndErrors.ExpectedNonZero(); } + if (to == address(0)) { revert CommonEventsAndErrors.InvalidAddress(); } + // Encodes the message before invoking _lzSend. + bytes memory _payload = abi.encode(to.addressToBytes32(), amount); + // debit + temple.burn(msg.sender, amount); + emit TempleTeleported(dstEid, msg.sender, to, amount); + + receipt = _lzSend(dstEid, _payload, options, MessagingFee(msg.value, 0), payable(msg.sender)); + } + + /** + * @dev External function to interact with the LayerZero EndpointV2.quote() for fee calculation. + * @param _dstEid The destination endpoint ID. + * @param _message The message payload. + * @param _options Additional options for the message. + * @return fee The calculated MessagingFee for the message. + * - nativeFee: The native fee for the message. + * - lzTokenFee: The LZ token fee for the message. + */ + function quote( + uint32 _dstEid, + bytes memory _message, + bytes memory _options + ) external view returns (MessagingFee memory fee) { + return _quote(_dstEid, _message, _options, false); + } + + /** + * @dev External function to interact with the LayerZero EndpointV2.quote() for fee calculation. + * @param _dstEid The destination endpoint ID. + * @param _to Recipient + * @param _amount Amount to send + * @param _options Additional options for the message. + * @return fee The calculated MessagingFee for the message. + * - nativeFee: The native fee for the message. + * - lzTokenFee: The LZ token fee for the message. + */ + function quote( + uint32 _dstEid, + address _to, + uint256 _amount, + bytes memory _options + ) external view returns (MessagingFee memory fee) { + return _quote(_dstEid, abi.encodePacked(_to.addressToBytes32(), _amount), _options, false); + } + + /// @dev Called when data is received from the protocol. It overrides the equivalent function in the parent contract. + /// Protocol messages are defined as packets, comprised of the following parameters. + /// @param _payload Encoded message. + function _lzReceive( + Origin calldata /*_origin*/, + bytes32 /*_guid*/, + bytes calldata _payload, + address /*_executor,*/, // Executor address as specified by the OApp. + bytes calldata /*_extraData */ // Any extra data or options to trigger on receipt. + ) internal override { + // Decode the payload to get the message + (address _recipient, uint256 _amount) = abi.decode(_payload, (address, uint256)); + temple.mint(_recipient, _amount); + } +} \ No newline at end of file diff --git a/protocol/hardhat.config.ts b/protocol/hardhat.config.ts index f1623aa90..a090b3677 100644 --- a/protocol/hardhat.config.ts +++ b/protocol/hardhat.config.ts @@ -223,6 +223,7 @@ module.exports = { goerli: process.env.ETHERSCAN_API_KEY, sepolia: process.env.ETHERSCAN_API_KEY, arbitrumSepolia: process.env.ARBISCAN_API_KEY, + cartio: process.env.CARTIO_API_KEY, }, customChains: [ { diff --git a/protocol/scripts/deploys/cartio/deploymentArgs/0x0090F9655a0B0A32cEE0Da5ae45E93EAB4C6d149.js b/protocol/scripts/deploys/cartio/deploymentArgs/0x0090F9655a0B0A32cEE0Da5ae45E93EAB4C6d149.js new file mode 100644 index 000000000..738c575e5 --- /dev/null +++ b/protocol/scripts/deploys/cartio/deploymentArgs/0x0090F9655a0B0A32cEE0Da5ae45E93EAB4C6d149.js @@ -0,0 +1,3 @@ +// cartio: TEMPLE=0x0090F9655a0B0A32cEE0Da5ae45E93EAB4C6d149 +// yarn hardhat verify --network cartio 0x0090F9655a0B0A32cEE0Da5ae45E93EAB4C6d149 --constructor-args scripts/deploys/cartio/deploymentArgs/0x0090F9655a0B0A32cEE0Da5ae45E93EAB4C6d149.js +module.exports = []; \ No newline at end of file diff --git a/protocol/scripts/deploys/cartio/deploymentArgs/0x192aA9BfDcA5540406E211950C226C8E0cd5047F.js b/protocol/scripts/deploys/cartio/deploymentArgs/0x192aA9BfDcA5540406E211950C226C8E0cd5047F.js new file mode 100644 index 000000000..795912c20 --- /dev/null +++ b/protocol/scripts/deploys/cartio/deploymentArgs/0x192aA9BfDcA5540406E211950C226C8E0cd5047F.js @@ -0,0 +1,7 @@ +// cartio: TEMPLE_GOLD_ADMIN=0x192aA9BfDcA5540406E211950C226C8E0cd5047F +// yarn hardhat verify --network cartio 0x192aA9BfDcA5540406E211950C226C8E0cd5047F --constructor-args scripts/deploys/cartio/deploymentArgs/0x192aA9BfDcA5540406E211950C226C8E0cd5047F.js +module.exports = [ + "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + "0xC785695710292c042a2de8A0Ba16F3a054cC2eAD", + "0x98c5E61b1B3731A1f379E8770861164d23118cdc" +]; \ No newline at end of file diff --git a/protocol/scripts/deploys/cartio/deploymentArgs/0x2ae6318e34bb97ae3755AFcE75559452aA223A5D.js b/protocol/scripts/deploys/cartio/deploymentArgs/0x2ae6318e34bb97ae3755AFcE75559452aA223A5D.js new file mode 100644 index 000000000..15a3c246a --- /dev/null +++ b/protocol/scripts/deploys/cartio/deploymentArgs/0x2ae6318e34bb97ae3755AFcE75559452aA223A5D.js @@ -0,0 +1,12 @@ +// cartio: TEMPLE_GOLD=0x2ae6318e34bb97ae3755AFcE75559452aA223A5D +// yarn hardhat verify --network cartio 0x2ae6318e34bb97ae3755AFcE75559452aA223A5D --constructor-args scripts/deploys/cartio/deploymentArgs/0x2ae6318e34bb97ae3755AFcE75559452aA223A5D.js +module.exports = [ + { + "executor": "0xC785695710292c042a2de8A0Ba16F3a054cC2eAD", + "layerZeroEndpoint": "0x6C7Ab2202C98C4227C5c46f1417D81144DA716Ff", + "mintChainId": 11155111, + "mintChainLzEid": 40161, + "name": "TEMPLE GOLD", + "symbol": "TGLD" + } +]; \ No newline at end of file diff --git a/protocol/scripts/deploys/cartio/deploymentArgs/0x98c5E61b1B3731A1f379E8770861164d23118cdc.js b/protocol/scripts/deploys/cartio/deploymentArgs/0x98c5E61b1B3731A1f379E8770861164d23118cdc.js new file mode 100644 index 000000000..beb629c37 --- /dev/null +++ b/protocol/scripts/deploys/cartio/deploymentArgs/0x98c5E61b1B3731A1f379E8770861164d23118cdc.js @@ -0,0 +1,12 @@ +// cartio: TEMPLE_GOLD=0x98c5E61b1B3731A1f379E8770861164d23118cdc +// yarn hardhat verify --network cartio 0x98c5E61b1B3731A1f379E8770861164d23118cdc --constructor-args scripts/deploys/cartio/deploymentArgs/0x98c5E61b1B3731A1f379E8770861164d23118cdc.js +module.exports = [ + { + "executor": "0xC785695710292c042a2de8A0Ba16F3a054cC2eAD", + "layerZeroEndpoint": "0x6C7Ab2202C98C4227C5c46f1417D81144DA716Ff", + "mintChainId": 80000, + "mintChainLzEid": 40346, + "name": "TEMPLE GOLD", + "symbol": "TGLD" + } +]; \ No newline at end of file diff --git a/protocol/scripts/deploys/cartio/deploymentArgs/0xBe9162230D9e637218D74C7f41f62ef2385fEe64.js b/protocol/scripts/deploys/cartio/deploymentArgs/0xBe9162230D9e637218D74C7f41f62ef2385fEe64.js new file mode 100644 index 000000000..286a9f169 --- /dev/null +++ b/protocol/scripts/deploys/cartio/deploymentArgs/0xBe9162230D9e637218D74C7f41f62ef2385fEe64.js @@ -0,0 +1,7 @@ +// cartio: TEMPLE_GOLD_ADMIN=0xBe9162230D9e637218D74C7f41f62ef2385fEe64 +// yarn hardhat verify --network cartio 0xBe9162230D9e637218D74C7f41f62ef2385fEe64 --constructor-args scripts/deploys/cartio/deploymentArgs/0xBe9162230D9e637218D74C7f41f62ef2385fEe64.js +module.exports = [ + "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + "0xC785695710292c042a2de8A0Ba16F3a054cC2eAD", + "0x2ae6318e34bb97ae3755AFcE75559452aA223A5D" +]; \ No newline at end of file diff --git a/protocol/scripts/deploys/cartio/deploymentArgs/0xcbc7cf85dd0AB91Aa2671400E86ebf3AaC6dc658.js b/protocol/scripts/deploys/cartio/deploymentArgs/0xcbc7cf85dd0AB91Aa2671400E86ebf3AaC6dc658.js new file mode 100644 index 000000000..521346a66 --- /dev/null +++ b/protocol/scripts/deploys/cartio/deploymentArgs/0xcbc7cf85dd0AB91Aa2671400E86ebf3AaC6dc658.js @@ -0,0 +1,7 @@ +// cartio: TEMPLE_TELEPORTER=0xcbc7cf85dd0AB91Aa2671400E86ebf3AaC6dc658 +// yarn hardhat verify --network cartio 0xcbc7cf85dd0AB91Aa2671400E86ebf3AaC6dc658 --constructor-args scripts/deploys/cartio/deploymentArgs/0xcbc7cf85dd0AB91Aa2671400E86ebf3AaC6dc658.js +module.exports = [ + "0xC785695710292c042a2de8A0Ba16F3a054cC2eAD", + "0x0090F9655a0B0A32cEE0Da5ae45E93EAB4C6d149", + "0x6C7Ab2202C98C4227C5c46f1417D81144DA716Ff" +]; \ No newline at end of file diff --git a/protocol/scripts/deploys/cartio/templegold/02-temple-gold.ts b/protocol/scripts/deploys/cartio/templegold/02-temple-gold.ts index 844f085a2..a20a4beec 100644 --- a/protocol/scripts/deploys/cartio/templegold/02-temple-gold.ts +++ b/protocol/scripts/deploys/cartio/templegold/02-temple-gold.ts @@ -12,14 +12,14 @@ async function main() { const [owner] = await ethers.getSigners(); const ownerAddress = await owner.getAddress(); const TEMPLEGOLD_ADDRESSES = getDeployedTempleGoldContracts(); - const CARTIO_TESTNET_CHAIN_ID = 80000; - const CARTIO_TESTNET_LZ_EID = 40346; + const MINT_CHAIN_ID = 11155111; // sepolia + const MINT_CHAIN_LZ_EID = 40161; // sepolia lz const _initArgs = { // Changed in transfer ownership to TempleAdmin executor: ownerAddress, // executor is also used as delegate in LayerZero Endpoint. layerZeroEndpoint: TEMPLEGOLD_ADDRESSES.EXTERNAL.LAYER_ZERO.ENDPOINT, // local endpoint address - mintChainId: CARTIO_TESTNET_CHAIN_ID, - mintChainLzEid: CARTIO_TESTNET_LZ_EID, + mintChainId: MINT_CHAIN_ID, + mintChainLzEid: MINT_CHAIN_LZ_EID, name: "TEMPLE GOLD", symbol: "TGLD" }; diff --git a/protocol/scripts/deploys/cartio/templegold/03-temple-teleporter.ts b/protocol/scripts/deploys/cartio/templegold/03-temple-teleporter.ts index 335b281a8..865a244ba 100644 --- a/protocol/scripts/deploys/cartio/templegold/03-temple-teleporter.ts +++ b/protocol/scripts/deploys/cartio/templegold/03-temple-teleporter.ts @@ -6,21 +6,19 @@ import { ensureExpectedEnvvars, } from '../../helpers'; import { getDeployedTempleGoldContracts } from '../../mainnet/templegold/contract-addresses'; -import { getDeployedContracts } from '../../mainnet/v2/contract-addresses'; async function main() { ensureExpectedEnvvars(); const [owner] = await ethers.getSigners(); const TEMPLEGOLD_ADDRESSES = getDeployedTempleGoldContracts(); - const CORE_ADDRESSES = getDeployedContracts(); const factory = new TempleTeleporter__factory(owner); await deployAndMine( 'TEMPLE_TELEPORTER', factory, factory.deploy, - CORE_ADDRESSES.CORE.EXECUTOR_MSIG, - CORE_ADDRESSES.CORE.TEMPLE_TOKEN, + await owner.getAddress(), // executor + TEMPLEGOLD_ADDRESSES.CORE.TEMPLE_TOKEN, TEMPLEGOLD_ADDRESSES.EXTERNAL.LAYER_ZERO.ENDPOINT ); } diff --git a/protocol/scripts/deploys/cartio/templegold/04-temple-gold-admin.ts b/protocol/scripts/deploys/cartio/templegold/04-temple-gold-admin.ts index b8c6184fd..6da0db24b 100644 --- a/protocol/scripts/deploys/cartio/templegold/04-temple-gold-admin.ts +++ b/protocol/scripts/deploys/cartio/templegold/04-temple-gold-admin.ts @@ -6,21 +6,20 @@ import { ensureExpectedEnvvars, } from '../../helpers'; import { getDeployedTempleGoldContracts } from '../../mainnet/templegold/contract-addresses'; -import { getDeployedContracts } from '../../mainnet/v2/contract-addresses'; async function main() { ensureExpectedEnvvars(); const [owner] = await ethers.getSigners(); const TEMPLEGOLD_ADDRESSES = getDeployedTempleGoldContracts(); - const CORE_ADDRESSES = getDeployedContracts(); + const rescuer = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"; const factory = new TempleGoldAdmin__factory(owner); await deployAndMine( 'TEMPLE_GOLD_ADMIN', factory, factory.deploy, - CORE_ADDRESSES.CORE.RESCUER_MSIG, - CORE_ADDRESSES.CORE.EXECUTOR_MSIG, + rescuer, // rescuer + await owner.getAddress(), // executor TEMPLEGOLD_ADDRESSES.TEMPLE_GOLD.TEMPLE_GOLD ); } diff --git a/protocol/scripts/deploys/cartio/templegold/999-ops.ts b/protocol/scripts/deploys/cartio/templegold/999-ops.ts new file mode 100644 index 000000000..ba99f6bcd --- /dev/null +++ b/protocol/scripts/deploys/cartio/templegold/999-ops.ts @@ -0,0 +1,35 @@ +import { ethers } from 'hardhat'; +import { + ensureExpectedEnvvars, + mine, +} from '../../helpers'; +import { connectToContracts, ContractInstances, ContractAddresses, getDeployedTempleGoldContracts } from '../../mainnet/templegold/contract-addresses'; + +async function main() { + ensureExpectedEnvvars(); + const [owner] = await ethers.getSigners(); + const TEMPLE_GOLD_ADDRESSES = getDeployedTempleGoldContracts(); + const TEMPLE_GOLD_INSTANCES = connectToContracts(owner); + + // Transfer ownership to the temple gold admin + await transferOwnerships(TEMPLE_GOLD_INSTANCES, TEMPLE_GOLD_ADDRESSES); + + await addMinter(TEMPLE_GOLD_INSTANCES, TEMPLE_GOLD_ADDRESSES.TEMPLE_GOLD.TEMPLE_TELEPORTER); +} + +async function transferOwnerships(instances: ContractInstances, addresses: ContractAddresses) { + await mine(instances.TEMPLE_GOLD.TEMPLE_GOLD.transferOwnership(addresses.TEMPLE_GOLD.TEMPLE_GOLD_ADMIN)); +} + +async function addMinter(instances: ContractInstances, minter: string) { + await mine(instances.CORE.TEMPLE_TOKEN.addMinter(minter)); +} + +// We recommend this pattern to be able to use async/await everywhere +// and properly handle errors. +main() + .then(() => process.exit(0)) + .catch(error => { + console.error(error); + process.exit(1); + }); diff --git a/protocol/scripts/deploys/cartio/templegold/999-transfer-ownership.ts b/protocol/scripts/deploys/cartio/templegold/999-transfer-ownership.ts deleted file mode 100644 index 6ada4bc31..000000000 --- a/protocol/scripts/deploys/cartio/templegold/999-transfer-ownership.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { ethers } from 'hardhat'; -import { - ensureExpectedEnvvars, - mine, -} from '../../helpers'; -import { connectToContracts, getDeployedTempleGoldContracts } from '../../mainnet/templegold/contract-addresses'; -import { getDeployedContracts } from "../../mainnet/v2/contract-addresses"; - -async function main() { - ensureExpectedEnvvars(); - const [owner] = await ethers.getSigners(); - const TEMPLE_GOLD_ADDRESSES = getDeployedTempleGoldContracts(); - const V2_ADDRESSES = getDeployedContracts(); - const TEMPLE_GOLD_INSTANCES = connectToContracts(owner); - - // Transfer ownership to the temple gold admin - await mine( - TEMPLE_GOLD_INSTANCES.TEMPLE_GOLD.TEMPLE_GOLD.transferOwnership( - TEMPLE_GOLD_ADDRESSES.TEMPLE_GOLD.TEMPLE_GOLD_ADMIN - ) - ); - // temple token - await mine( - TEMPLE_GOLD_INSTANCES.CORE.TEMPLE_TOKEN.transferOwnership( - V2_ADDRESSES.CORE.EXECUTOR_MSIG - ) - ); - // temple teleporter - await mine( - TEMPLE_GOLD_INSTANCES.TEMPLE_GOLD.TEMPLE_TELEPORTER.transferOwnership( - V2_ADDRESSES.CORE.EXECUTOR_MSIG - ) - ); -} - -// We recommend this pattern to be able to use async/await everywhere -// and properly handle errors. -main() - .then(() => process.exit(0)) - .catch(error => { - console.error(error); - process.exit(1); - }); diff --git a/protocol/scripts/deploys/helpers.ts b/protocol/scripts/deploys/helpers.ts index 36c80730d..a28f58afb 100644 --- a/protocol/scripts/deploys/helpers.ts +++ b/protocol/scripts/deploys/helpers.ts @@ -688,6 +688,7 @@ const expectedEnvvars: { [key: string]: string[] } = { polygonMumbai: ['MUMBAI_ADDRESS_PRIVATE_KEY', 'MUMBAI_RPC_URL'], sepolia: ['SEPOLIA_ADDRESS_PRIVATE_KEY', 'SEPOLIA_RPC_URL'], arbitrumSepolia: ['ARBITRUM_SEPOLIA_ADDRESS_PRIVATE_KEY', 'ARBITRUM_SEPOLIA_RPC_URL'], + cartio: ['CARTIO_ADDRESS_PRIVATE_KEY', 'CARTIO_RPC_URL'], anvil: [], localhost: [], }; diff --git a/protocol/scripts/deploys/mainnet/templegold/contract-addresses.ts b/protocol/scripts/deploys/mainnet/templegold/contract-addresses.ts index 4f2dd3963..60126f1f5 100644 --- a/protocol/scripts/deploys/mainnet/templegold/contract-addresses.ts +++ b/protocol/scripts/deploys/mainnet/templegold/contract-addresses.ts @@ -40,6 +40,11 @@ export interface ContractAddresses { } } +export interface PeerInfo { + destEid: number, + chainId: number, +} + const TEMPLEGOLD_DEPLOYED_CONTRACTS: {[key: string]: ContractAddresses} = { arbitrumOne: { TEMPLE_GOLD: { @@ -103,7 +108,7 @@ const TEMPLEGOLD_DEPLOYED_CONTRACTS: {[key: string]: ContractAddresses} = { TEMPLE_GOLD: "0x2ae6318e34bb97ae3755AFcE75559452aA223A5D", TEMPLE_GOLD_ADMIN: "string", TEMPLE_GOLD_STAKING: "0xdbDAc0FCA9cF8CA2F2Ef718775f0F265f581808F", - TEMPLE_TELEPORTER: "0x7De0066A6BD454B2Ecaeb3E54814458a71D345A5", + TEMPLE_TELEPORTER: "0x7455A2bDbE76d36c835824D9A41E6842216d6c36",//"0x8ef2c51FeB8539b692596f6b6b2867Ae7154ceAe", SPICE_AUCTION: "string", SPICE_AUCTION_FACTORY: "0x0231340BBAf990B3Aa9f2B095b9DC11e493059c1", STABLE_GOLD_AUCTION: "0x8d3671d794d511Bb0E3D28e260F8E2233C0653aB", @@ -127,10 +132,10 @@ const TEMPLEGOLD_DEPLOYED_CONTRACTS: {[key: string]: ContractAddresses} = { AUCTION_AUTOMATION_EOA: "string", STAKING_AUTOMATION_EOA: "string", SPICE_AUCTION_OPERATOR: "string", - TEMPLE_GOLD: "string", - TEMPLE_GOLD_ADMIN: "string", + TEMPLE_GOLD: "0x2ae6318e34bb97ae3755AFcE75559452aA223A5D", + TEMPLE_GOLD_ADMIN: "0xBe9162230D9e637218D74C7f41f62ef2385fEe64", TEMPLE_GOLD_STAKING: "string", - TEMPLE_TELEPORTER: "string", + TEMPLE_TELEPORTER: "0xcbc7cf85dd0AB91Aa2671400E86ebf3AaC6dc658", SPICE_AUCTION: "string", SPICE_AUCTION_FACTORY: "string", STABLE_GOLD_AUCTION: "string", @@ -138,7 +143,7 @@ const TEMPLEGOLD_DEPLOYED_CONTRACTS: {[key: string]: ContractAddresses} = { RESCUER_MSIG: "string", }, CORE: { - TEMPLE_TOKEN: "string", + TEMPLE_TOKEN: "0x0090F9655a0B0A32cEE0Da5ae45E93EAB4C6d149", }, EXTERNAL: { LAYER_ZERO: { @@ -205,6 +210,21 @@ const TEMPLEGOLD_DEPLOYED_CONTRACTS: {[key: string]: ContractAddresses} = { } } +const PEER_INFO: { [key: string]: PeerInfo } = { + cartio: { + destEid: 40346, + chainId: 80000 + }, + sepolia: { + destEid: 40161, + chainId: 11155111 + }, + arbitrumSepolia: { + destEid: 40231, + chainId: 421614 + } +} + export function getDeployedTempleGoldContracts(): ContractAddresses { if (TEMPLEGOLD_DEPLOYED_CONTRACTS[network.name] === undefined) { console.log(`No contracts configured for ${network.name}`); @@ -214,6 +234,15 @@ export function getDeployedTempleGoldContracts(): ContractAddresses { } } +export function getPeerInfo(network: string): PeerInfo { + if (PEER_INFO[network] === undefined) { + console.log(`No peer info configured for ${network}`); + throw new Error(`No peer info configured for ${network}`); + } else { + return PEER_INFO[network]; + } +} + export interface ContractInstances { TEMPLE_GOLD: { TEMPLE_GOLD: TempleGold, diff --git a/protocol/scripts/deploys/sepolia/deploymentArgs/0x7455A2bDbE76d36c835824D9A41E6842216d6c36.js b/protocol/scripts/deploys/sepolia/deploymentArgs/0x7455A2bDbE76d36c835824D9A41E6842216d6c36.js new file mode 100644 index 000000000..3e9f34ecb --- /dev/null +++ b/protocol/scripts/deploys/sepolia/deploymentArgs/0x7455A2bDbE76d36c835824D9A41E6842216d6c36.js @@ -0,0 +1,7 @@ +// sepolia: TEMPLE_TELEPORTER=0x7455A2bDbE76d36c835824D9A41E6842216d6c36 +// yarn hardhat verify --network sepolia 0x7455A2bDbE76d36c835824D9A41E6842216d6c36 --constructor-args scripts/deploys/sepolia/deploymentArgs/0x7455A2bDbE76d36c835824D9A41E6842216d6c36.js +module.exports = [ + "0xC785695710292c042a2de8A0Ba16F3a054cC2eAD", + "0x98c5E61b1B3731A1f379E8770861164d23118cdc", + "0x6EDCE65403992e310A62460808c4b910D972f10f" +]; \ No newline at end of file diff --git a/protocol/scripts/deploys/sepolia/deploymentArgs/0x8ef2c51FeB8539b692596f6b6b2867Ae7154ceAe.js b/protocol/scripts/deploys/sepolia/deploymentArgs/0x8ef2c51FeB8539b692596f6b6b2867Ae7154ceAe.js new file mode 100644 index 000000000..61a4a4581 --- /dev/null +++ b/protocol/scripts/deploys/sepolia/deploymentArgs/0x8ef2c51FeB8539b692596f6b6b2867Ae7154ceAe.js @@ -0,0 +1,7 @@ +// sepolia: TEMPLE_TELEPORTER=0x8ef2c51FeB8539b692596f6b6b2867Ae7154ceAe +// yarn hardhat verify --network sepolia 0x8ef2c51FeB8539b692596f6b6b2867Ae7154ceAe --constructor-args scripts/deploys/sepolia/deploymentArgs/0x8ef2c51FeB8539b692596f6b6b2867Ae7154ceAe.js +module.exports = [ + "0xC785695710292c042a2de8A0Ba16F3a054cC2eAD", + "0x98c5E61b1B3731A1f379E8770861164d23118cdc", + "0x6EDCE65403992e310A62460808c4b910D972f10f" +]; \ No newline at end of file diff --git a/protocol/scripts/deploys/sepolia/templegold/03-temple-teleporter.ts b/protocol/scripts/deploys/sepolia/templegold/03-temple-teleporter.ts index d1867d7ec..8889554a0 100644 --- a/protocol/scripts/deploys/sepolia/templegold/03-temple-teleporter.ts +++ b/protocol/scripts/deploys/sepolia/templegold/03-temple-teleporter.ts @@ -1,27 +1,24 @@ import '@nomiclabs/hardhat-ethers'; import { ethers } from 'hardhat'; -import { TempleTeleporter__factory } from '../../../../typechain'; +import { TempleTeleporterTestnet__factory } from '../../../../typechain'; import { deployAndMine, ensureExpectedEnvvars, } from '../../helpers'; import { getDeployedTempleGoldContracts } from '../../mainnet/templegold/contract-addresses'; -import { getDeployedContracts } from '../v2/contract-addresses'; async function main() { ensureExpectedEnvvars(); const [owner] = await ethers.getSigners(); const TEMPLEGOLD_ADDRESSES = getDeployedTempleGoldContracts(); - const CORE_ADDRESSES = getDeployedContracts(); - - const factory = new TempleTeleporter__factory(owner); + const factory = new TempleTeleporterTestnet__factory(owner); await deployAndMine( 'TEMPLE_TELEPORTER', factory, factory.deploy, await owner.getAddress(), // executor - CORE_ADDRESSES.CORE.TEMPLE_TOKEN, + TEMPLEGOLD_ADDRESSES.CORE.TEMPLE_TOKEN, TEMPLEGOLD_ADDRESSES.EXTERNAL.LAYER_ZERO.ENDPOINT ); } diff --git a/protocol/scripts/deploys/sepolia/templegold/99-ops.ts b/protocol/scripts/deploys/sepolia/templegold/99-ops.ts new file mode 100644 index 000000000..a926ce8e5 --- /dev/null +++ b/protocol/scripts/deploys/sepolia/templegold/99-ops.ts @@ -0,0 +1,43 @@ +import '@nomiclabs/hardhat-ethers'; +import { ethers } from 'hardhat'; +import { + mine, + ensureExpectedEnvvars, +} from '../../helpers'; +import { connectToContracts, + getPeerInfo, ContractInstances } from '../../mainnet/templegold/contract-addresses'; + +async function main() { + ensureExpectedEnvvars(); + const [owner] = await ethers.getSigners(); + const TEMPLE_GOLD_INSTANCES = connectToContracts(owner); + const cartioInfo = getPeerInfo("cartio"); + // showing examples + // const to = "0xcbc7cf85dd0AB91Aa2671400E86ebf3AaC6dc658"; + // await setPeer(TEMPLE_GOLD_INSTANCES, to, cartioInfo.destEid); + // await teleport(TEMPLE_GOLD_INSTANCES, cartioInfo.destEid, await owner.getAddress()); +} + +async function setPeer(instances: ContractInstances, to: string, destEid: number) { + await mine(instances.TEMPLE_GOLD.TEMPLE_TELEPORTER.setPeer(destEid, addressToBytes32(to))); +} + +function addressToBytes32(address: string) { + return ethers.utils.zeroPad(address, 32); +} + +async function teleport(instances: ContractInstances,destEid: number, to: string) { + const amount = ethers.utils.parseEther("10"); + // bytes memory options = OptionsBuilder.newOptions().addExecutorLzReceiveOption(200000, 0); + const options = "0x00030100110100000000000000000000000000030d40"; + await mine(instances.TEMPLE_GOLD.TEMPLE_TELEPORTER.teleport(destEid, to, amount, options, {value:59342083465093})); +} + +// We recommend this pattern to be able to use async/await everywhere +// and properly handle errors. +main() + .then(() => process.exit(0)) + .catch(error => { + console.error(error); + process.exit(1); + }); \ No newline at end of file