Can not deploy in devnet with the script

I am trying to deploy a contract with the following script:

const deploy_trx = new TransactionBlock();

  const [upgradeCap] = deploy_trx.publish({
    modules,
    dependencies,
  });

  deploy_trx.transferObjects(
    [upgradeCap],
    deploy_trx.pure(keypair.toSuiAddress())
  );

  const { objectChanges, balanceChanges } =
    await client.signAndExecuteTransactionBlock({
      signer: keypair,
      transactionBlock: deploy_trx,
      options: {
        showBalanceChanges: true,
        showEffects: true,
        showEvents: true,
        showInput: false,
        showObjectChanges: true,
        showRawInput: false,
      },
    });

So when I am deploying a contract in devnet with this script I get the following error:

 error: JsonRpcError: Fail to retrieve Object layout for 0x2::transfer_policy::TransferPolicyCreated<0xdd2e670fa289cfc56b2b9f597ad1412eec3550e81b1185bad8b8369c2b66c2e::protocol::Channel>

But when I am deploying with the same script in testnet it’s working. How do I resolve this issue?