Tenderly / hardhat-tenderly

Tenderly plugin for HardHat
https://www.npmjs.com/package/@tenderly/hardhat-tenderly
Other
154 stars 40 forks source link

Tenderly devnet verification can't work properly in case of multiple devnets. #156

Open liu-zhipeng opened 1 year ago

liu-zhipeng commented 1 year ago

I am using 3 tenderly devnets for testing cross-chain app.

"devnet-mainnet": {
    accounts: { mnemonic },
    chainId: 1,
    url: process.env.MAINNET_DEVNET_RPC_URL || "http://localhost:8545",
  },
  "devnet-optimism": {
    accounts: { mnemonic },
    chainId: 10,
    url: process.env.OPTIMISM_DEVNET_RPC_URL || "http://localhost:8545",
    companionNetworks: {
      hub: "devnet-mainnet",
    },
  },
  "devnet-gnosis": {
    accounts: { mnemonic },
    chainId: 100,
    url: process.env.GNOSIS_DEVNET_RPC_URL || "http://localhost:8545",
    companionNetworks: {
      hub: "devnet-mainnet",
    },
  },

But devnet verification is not working properly for my contracts. so i investigated why.

https://github.com/Tenderly/hardhat-tenderly/blob/03b7c96dd7beb8f109a9f8e22df21d8d4a3d5a1d/packages/tenderly-hardhat/src/utils/util.ts#L429

hardhat-tenderly checks if the network name equals to devnet to check if current network is tenderly devnet. but i can't name devnet for all 3 my devnets.

export const isTenderlyNetworkName = (name: string): boolean => {
  return name.includes("tenderly") || name.includes("devnet")
}

I think above code would be hot fix for this problem.

milosdjak commented 1 year ago
networks: {
    devnet_mainnet: {
      url: '<DEVNET_RPC_URL>',
      // This will allow us to use our private key for signing later
      accounts: [`<PRIVATE_KEY>`],
      // This is the mainnet chain ID
      chainId: 1,
    },
    devnet_optimism: {
      url: '<DEVNET_RPC_URL>',
      // This will allow us to use our private key for signing later
      accounts: [`<PRIVATE_KEY>`],
      // This is the optimism chain ID
      chainId: 10,
    },
    devnet_gnosis: {
      url: '<DEVNET_RPC_URL>',
      // This will allow us to use our private key for signing later
      accounts: [`<PRIVATE_KEY>`],
      // This is the gnosis chain ID
      chainId: 100,
    },
You can set it like this and the command is:
`npx hardhat run scripts/deploy.js --network devnet_NETWORK`
liu-zhipeng commented 1 year ago
networks: {
    devnet_mainnet: {
      url: '<DEVNET_RPC_URL>',
      // This will allow us to use our private key for signing later
      accounts: [`<PRIVATE_KEY>`],
      // This is the mainnet chain ID
      chainId: 1,
    },
    devnet_optimism: {
      url: '<DEVNET_RPC_URL>',
      // This will allow us to use our private key for signing later
      accounts: [`<PRIVATE_KEY>`],
      // This is the optimism chain ID
      chainId: 10,
    },
    devnet_gnosis: {
      url: '<DEVNET_RPC_URL>',
      // This will allow us to use our private key for signing later
      accounts: [`<PRIVATE_KEY>`],
      // This is the gnosis chain ID
      chainId: 100,
    },
You can set it like this and the command is:
`npx hardhat run scripts/deploy.js --network devnet_NETWORK`

deploying contracts to devnet works properly. But verification is not working.

milosdjak commented 1 year ago

Sorry for the misunderstanding, you can verify it using this code above through UI. But for automatic verification, this is not possible for multiple devnets, I'll make a ticket for our product team. Thanks for your feedback and sorry for the inconvenience.

liu-zhipeng commented 1 year ago

Ok, Thank you.

liu-zhipeng commented 1 year ago

Please consider above hot fix which i wrote. :)

milosdjak commented 1 year ago

I'll make a ticket for our product team. You can create a script that will inject devnet url into your environment variables and have the hardhat config read the devnet RPC URL from your ENV variables and this should work. The other option is to switch manually your RPC for each network. Automatic verification works for the same network.

liu-zhipeng commented 1 year ago

I'll make a ticket for our product team. You can create a script that will inject devnet url into your environment variables and have the hardhat config read the devnet RPC URL from your ENV variables and this should work. The other option is to switch manually your RPC for each network. Automatic verification works for the same network.

Yep. maybe that might work, but i believe that will cause many other problems like exporting.